repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
geomet/geomet
geomet/wkb.py
_dump_point
def _dump_point(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. :param dict meta: Metadata associated with the GeoJSON object. Currently supported metadata: - srid: Used to support EWKT/EWKB. For example, ``meta`` equal to ``{'srid': '4326'}`` indicates that the geometry is defined using Extended WKT/WKB and that it bears a Spatial Reference System Identifier of 4326. This ID will be encoded into the resulting binary. Any other meta data objects will simply be ignored by this function. :returns: A WKB binary string representing of the Point ``obj``. """ coords = obj['coordinates'] num_dims = len(coords) wkb_string, byte_fmt, _ = _header_bytefmt_byteorder( 'Point', num_dims, big_endian, meta ) wkb_string += struct.pack(byte_fmt, *coords) return wkb_string
python
def _dump_point(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. :param dict meta: Metadata associated with the GeoJSON object. Currently supported metadata: - srid: Used to support EWKT/EWKB. For example, ``meta`` equal to ``{'srid': '4326'}`` indicates that the geometry is defined using Extended WKT/WKB and that it bears a Spatial Reference System Identifier of 4326. This ID will be encoded into the resulting binary. Any other meta data objects will simply be ignored by this function. :returns: A WKB binary string representing of the Point ``obj``. """ coords = obj['coordinates'] num_dims = len(coords) wkb_string, byte_fmt, _ = _header_bytefmt_byteorder( 'Point', num_dims, big_endian, meta ) wkb_string += struct.pack(byte_fmt, *coords) return wkb_string
[ "def", "_dump_point", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "num_dims", "=", "len", "(", "coords", ")", "wkb_string", ",", "byte_fmt", ",", "_", "=", "_header_bytefmt_byteorder", "(", "'Point'", ",", "num_dims", ",", "big_endian", ",", "meta", ")", "wkb_string", "+=", "struct", ".", "pack", "(", "byte_fmt", ",", "*", "coords", ")", "return", "wkb_string" ]
Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. :param dict meta: Metadata associated with the GeoJSON object. Currently supported metadata: - srid: Used to support EWKT/EWKB. For example, ``meta`` equal to ``{'srid': '4326'}`` indicates that the geometry is defined using Extended WKT/WKB and that it bears a Spatial Reference System Identifier of 4326. This ID will be encoded into the resulting binary. Any other meta data objects will simply be ignored by this function. :returns: A WKB binary string representing of the Point ``obj``.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "point", "WKB", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L379-L411
geomet/geomet
geomet/wkb.py
_dump_linestring
def _dump_linestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] # Infer the number of dimensions from the first vertex num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'LineString', num_dims, big_endian, meta ) # append number of vertices in linestring wkb_string += struct.pack('%sl' % byte_order, len(coords)) for vertex in coords: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
python
def _dump_linestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] # Infer the number of dimensions from the first vertex num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'LineString', num_dims, big_endian, meta ) # append number of vertices in linestring wkb_string += struct.pack('%sl' % byte_order, len(coords)) for vertex in coords: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
[ "def", "_dump_linestring", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "# Infer the number of dimensions from the first vertex", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",", "byte_fmt", ",", "byte_order", "=", "_header_bytefmt_byteorder", "(", "'LineString'", ",", "num_dims", ",", "big_endian", ",", "meta", ")", "# append number of vertices in linestring", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "coords", ")", ")", "for", "vertex", "in", "coords", ":", "wkb_string", "+=", "struct", ".", "pack", "(", "byte_fmt", ",", "*", "vertex", ")", "return", "wkb_string" ]
Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "linestring", "WKB", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L414-L434
geomet/geomet
geomet/wkb.py
_dump_multipoint
def _dump_multipoint(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiPoint', num_dims, big_endian, meta ) point_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['Point'] if big_endian: point_type = BIG_ENDIAN + point_type else: point_type = LITTLE_ENDIAN + point_type[::-1] wkb_string += struct.pack('%sl' % byte_order, len(coords)) for vertex in coords: # POINT type strings wkb_string += point_type wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
python
def _dump_multipoint(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiPoint', num_dims, big_endian, meta ) point_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['Point'] if big_endian: point_type = BIG_ENDIAN + point_type else: point_type = LITTLE_ENDIAN + point_type[::-1] wkb_string += struct.pack('%sl' % byte_order, len(coords)) for vertex in coords: # POINT type strings wkb_string += point_type wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
[ "def", "_dump_multipoint", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",", "byte_fmt", ",", "byte_order", "=", "_header_bytefmt_byteorder", "(", "'MultiPoint'", ",", "num_dims", ",", "big_endian", ",", "meta", ")", "point_type", "=", "_WKB", "[", "_INT_TO_DIM_LABEL", ".", "get", "(", "num_dims", ")", "]", "[", "'Point'", "]", "if", "big_endian", ":", "point_type", "=", "BIG_ENDIAN", "+", "point_type", "else", ":", "point_type", "=", "LITTLE_ENDIAN", "+", "point_type", "[", ":", ":", "-", "1", "]", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "coords", ")", ")", "for", "vertex", "in", "coords", ":", "# POINT type strings", "wkb_string", "+=", "point_type", "wkb_string", "+=", "struct", ".", "pack", "(", "byte_fmt", ",", "*", "vertex", ")", "return", "wkb_string" ]
Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "multipoint", "WKB", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L463-L489
geomet/geomet
geomet/wkb.py
_dump_multilinestring
def _dump_multilinestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiLineString', num_dims, big_endian, meta ) ls_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['LineString'] if big_endian: ls_type = BIG_ENDIAN + ls_type else: ls_type = LITTLE_ENDIAN + ls_type[::-1] # append the number of linestrings wkb_string += struct.pack('%sl' % byte_order, len(coords)) for linestring in coords: wkb_string += ls_type # append the number of vertices in each linestring wkb_string += struct.pack('%sl' % byte_order, len(linestring)) for vertex in linestring: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
python
def _dump_multilinestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiLineString', num_dims, big_endian, meta ) ls_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['LineString'] if big_endian: ls_type = BIG_ENDIAN + ls_type else: ls_type = LITTLE_ENDIAN + ls_type[::-1] # append the number of linestrings wkb_string += struct.pack('%sl' % byte_order, len(coords)) for linestring in coords: wkb_string += ls_type # append the number of vertices in each linestring wkb_string += struct.pack('%sl' % byte_order, len(linestring)) for vertex in linestring: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
[ "def", "_dump_multilinestring", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "[", "0", "]", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",", "byte_fmt", ",", "byte_order", "=", "_header_bytefmt_byteorder", "(", "'MultiLineString'", ",", "num_dims", ",", "big_endian", ",", "meta", ")", "ls_type", "=", "_WKB", "[", "_INT_TO_DIM_LABEL", ".", "get", "(", "num_dims", ")", "]", "[", "'LineString'", "]", "if", "big_endian", ":", "ls_type", "=", "BIG_ENDIAN", "+", "ls_type", "else", ":", "ls_type", "=", "LITTLE_ENDIAN", "+", "ls_type", "[", ":", ":", "-", "1", "]", "# append the number of linestrings", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "coords", ")", ")", "for", "linestring", "in", "coords", ":", "wkb_string", "+=", "ls_type", "# append the number of vertices in each linestring", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "linestring", ")", ")", "for", "vertex", "in", "linestring", ":", "wkb_string", "+=", "struct", ".", "pack", "(", "byte_fmt", ",", "*", "vertex", ")", "return", "wkb_string" ]
Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "multilinestring", "WKB", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L492-L522
geomet/geomet
geomet/wkb.py
_dump_multipolygon
def _dump_multipolygon(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipolygon WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiPolygon', num_dims, big_endian, meta ) poly_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['Polygon'] if big_endian: poly_type = BIG_ENDIAN + poly_type else: poly_type = LITTLE_ENDIAN + poly_type[::-1] # apped the number of polygons wkb_string += struct.pack('%sl' % byte_order, len(coords)) for polygon in coords: # append polygon header wkb_string += poly_type # append the number of rings in this polygon wkb_string += struct.pack('%sl' % byte_order, len(polygon)) for ring in polygon: # append the number of vertices in this ring wkb_string += struct.pack('%sl' % byte_order, len(ring)) for vertex in ring: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
python
def _dump_multipolygon(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipolygon WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder( 'MultiPolygon', num_dims, big_endian, meta ) poly_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['Polygon'] if big_endian: poly_type = BIG_ENDIAN + poly_type else: poly_type = LITTLE_ENDIAN + poly_type[::-1] # apped the number of polygons wkb_string += struct.pack('%sl' % byte_order, len(coords)) for polygon in coords: # append polygon header wkb_string += poly_type # append the number of rings in this polygon wkb_string += struct.pack('%sl' % byte_order, len(polygon)) for ring in polygon: # append the number of vertices in this ring wkb_string += struct.pack('%sl' % byte_order, len(ring)) for vertex in ring: wkb_string += struct.pack(byte_fmt, *vertex) return wkb_string
[ "def", "_dump_multipolygon", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "[", "0", "]", "[", "0", "]", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",", "byte_fmt", ",", "byte_order", "=", "_header_bytefmt_byteorder", "(", "'MultiPolygon'", ",", "num_dims", ",", "big_endian", ",", "meta", ")", "poly_type", "=", "_WKB", "[", "_INT_TO_DIM_LABEL", ".", "get", "(", "num_dims", ")", "]", "[", "'Polygon'", "]", "if", "big_endian", ":", "poly_type", "=", "BIG_ENDIAN", "+", "poly_type", "else", ":", "poly_type", "=", "LITTLE_ENDIAN", "+", "poly_type", "[", ":", ":", "-", "1", "]", "# apped the number of polygons", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "coords", ")", ")", "for", "polygon", "in", "coords", ":", "# append polygon header", "wkb_string", "+=", "poly_type", "# append the number of rings in this polygon", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "polygon", ")", ")", "for", "ring", "in", "polygon", ":", "# append the number of vertices in this ring", "wkb_string", "+=", "struct", ".", "pack", "(", "'%sl'", "%", "byte_order", ",", "len", "(", "ring", ")", ")", "for", "vertex", "in", "ring", ":", "wkb_string", "+=", "struct", ".", "pack", "(", "byte_fmt", ",", "*", "vertex", ")", "return", "wkb_string" ]
Dump a GeoJSON-like `dict` to a multipolygon WKB string. Input parameters and output are similar to :funct:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "multipolygon", "WKB", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L525-L559
geomet/geomet
geomet/wkb.py
_load_point
def _load_point(big_endian, type_bytes, data_bytes): """ Convert byte data for a Point to a GeoJSON `dict`. :param bool big_endian: If `True`, interpret the ``data_bytes`` in big endian order, else little endian. :param str type_bytes: 4-byte integer (as a binary string) indicating the geometry type (Point) and the dimensions (2D, Z, M or ZM). For consistency, these bytes are expected to always be in big endian order, regardless of the value of ``big_endian``. :param str data_bytes: Coordinate data in a binary string. :returns: GeoJSON `dict` representing the Point geometry. """ endian_token = '>' if big_endian else '<' if type_bytes == WKB_2D['Point']: coords = struct.unpack('%sdd' % endian_token, as_bin_str(take(16, data_bytes))) elif type_bytes == WKB_Z['Point']: coords = struct.unpack('%sddd' % endian_token, as_bin_str(take(24, data_bytes))) elif type_bytes == WKB_M['Point']: # NOTE: The use of XYM types geometries is quite rare. In the interest # of removing ambiguity, we will treat all XYM geometries as XYZM when # generate the GeoJSON. A default Z value of `0.0` will be given in # this case. coords = list(struct.unpack('%sddd' % endian_token, as_bin_str(take(24, data_bytes)))) coords.insert(2, 0.0) elif type_bytes == WKB_ZM['Point']: coords = struct.unpack('%sdddd' % endian_token, as_bin_str(take(32, data_bytes))) return dict(type='Point', coordinates=list(coords))
python
def _load_point(big_endian, type_bytes, data_bytes): """ Convert byte data for a Point to a GeoJSON `dict`. :param bool big_endian: If `True`, interpret the ``data_bytes`` in big endian order, else little endian. :param str type_bytes: 4-byte integer (as a binary string) indicating the geometry type (Point) and the dimensions (2D, Z, M or ZM). For consistency, these bytes are expected to always be in big endian order, regardless of the value of ``big_endian``. :param str data_bytes: Coordinate data in a binary string. :returns: GeoJSON `dict` representing the Point geometry. """ endian_token = '>' if big_endian else '<' if type_bytes == WKB_2D['Point']: coords = struct.unpack('%sdd' % endian_token, as_bin_str(take(16, data_bytes))) elif type_bytes == WKB_Z['Point']: coords = struct.unpack('%sddd' % endian_token, as_bin_str(take(24, data_bytes))) elif type_bytes == WKB_M['Point']: # NOTE: The use of XYM types geometries is quite rare. In the interest # of removing ambiguity, we will treat all XYM geometries as XYZM when # generate the GeoJSON. A default Z value of `0.0` will be given in # this case. coords = list(struct.unpack('%sddd' % endian_token, as_bin_str(take(24, data_bytes)))) coords.insert(2, 0.0) elif type_bytes == WKB_ZM['Point']: coords = struct.unpack('%sdddd' % endian_token, as_bin_str(take(32, data_bytes))) return dict(type='Point', coordinates=list(coords))
[ "def", "_load_point", "(", "big_endian", ",", "type_bytes", ",", "data_bytes", ")", ":", "endian_token", "=", "'>'", "if", "big_endian", "else", "'<'", "if", "type_bytes", "==", "WKB_2D", "[", "'Point'", "]", ":", "coords", "=", "struct", ".", "unpack", "(", "'%sdd'", "%", "endian_token", ",", "as_bin_str", "(", "take", "(", "16", ",", "data_bytes", ")", ")", ")", "elif", "type_bytes", "==", "WKB_Z", "[", "'Point'", "]", ":", "coords", "=", "struct", ".", "unpack", "(", "'%sddd'", "%", "endian_token", ",", "as_bin_str", "(", "take", "(", "24", ",", "data_bytes", ")", ")", ")", "elif", "type_bytes", "==", "WKB_M", "[", "'Point'", "]", ":", "# NOTE: The use of XYM types geometries is quite rare. In the interest", "# of removing ambiguity, we will treat all XYM geometries as XYZM when", "# generate the GeoJSON. A default Z value of `0.0` will be given in", "# this case.", "coords", "=", "list", "(", "struct", ".", "unpack", "(", "'%sddd'", "%", "endian_token", ",", "as_bin_str", "(", "take", "(", "24", ",", "data_bytes", ")", ")", ")", ")", "coords", ".", "insert", "(", "2", ",", "0.0", ")", "elif", "type_bytes", "==", "WKB_ZM", "[", "'Point'", "]", ":", "coords", "=", "struct", ".", "unpack", "(", "'%sdddd'", "%", "endian_token", ",", "as_bin_str", "(", "take", "(", "32", ",", "data_bytes", ")", ")", ")", "return", "dict", "(", "type", "=", "'Point'", ",", "coordinates", "=", "list", "(", "coords", ")", ")" ]
Convert byte data for a Point to a GeoJSON `dict`. :param bool big_endian: If `True`, interpret the ``data_bytes`` in big endian order, else little endian. :param str type_bytes: 4-byte integer (as a binary string) indicating the geometry type (Point) and the dimensions (2D, Z, M or ZM). For consistency, these bytes are expected to always be in big endian order, regardless of the value of ``big_endian``. :param str data_bytes: Coordinate data in a binary string. :returns: GeoJSON `dict` representing the Point geometry.
[ "Convert", "byte", "data", "for", "a", "Point", "to", "a", "GeoJSON", "dict", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L595-L633
geomet/geomet
geomet/wkt.py
dumps
def dumps(obj, decimals=16): """ Dump a GeoJSON-like `dict` to a WKT string. """ try: geom_type = obj['type'] exporter = _dumps_registry.get(geom_type) if exporter is None: _unsupported_geom_type(geom_type) # Check for empty cases if geom_type == 'GeometryCollection': if len(obj['geometries']) == 0: return 'GEOMETRYCOLLECTION EMPTY' else: # Geom has no coordinate values at all, and must be empty. if len(list(util.flatten_multi_dim(obj['coordinates']))) == 0: return '%s EMPTY' % geom_type.upper() except KeyError: raise geomet.InvalidGeoJSONException('Invalid GeoJSON: %s' % obj) result = exporter(obj, decimals) # Try to get the SRID from `meta.srid` meta_srid = obj.get('meta', {}).get('srid') # Also try to get it from `crs.properties.name`: crs_srid = obj.get('crs', {}).get('properties', {}).get('name') if crs_srid is not None: # Shave off the EPSG prefix to give us the SRID: crs_srid = crs_srid.replace('EPSG', '') if (meta_srid is not None and crs_srid is not None and str(meta_srid) != str(crs_srid)): raise ValueError( 'Ambiguous CRS/SRID values: %s and %s' % (meta_srid, crs_srid) ) srid = meta_srid or crs_srid # TODO: add tests for CRS input if srid is not None: # Prepend the SRID result = 'SRID=%s;%s' % (srid, result) return result
python
def dumps(obj, decimals=16): """ Dump a GeoJSON-like `dict` to a WKT string. """ try: geom_type = obj['type'] exporter = _dumps_registry.get(geom_type) if exporter is None: _unsupported_geom_type(geom_type) # Check for empty cases if geom_type == 'GeometryCollection': if len(obj['geometries']) == 0: return 'GEOMETRYCOLLECTION EMPTY' else: # Geom has no coordinate values at all, and must be empty. if len(list(util.flatten_multi_dim(obj['coordinates']))) == 0: return '%s EMPTY' % geom_type.upper() except KeyError: raise geomet.InvalidGeoJSONException('Invalid GeoJSON: %s' % obj) result = exporter(obj, decimals) # Try to get the SRID from `meta.srid` meta_srid = obj.get('meta', {}).get('srid') # Also try to get it from `crs.properties.name`: crs_srid = obj.get('crs', {}).get('properties', {}).get('name') if crs_srid is not None: # Shave off the EPSG prefix to give us the SRID: crs_srid = crs_srid.replace('EPSG', '') if (meta_srid is not None and crs_srid is not None and str(meta_srid) != str(crs_srid)): raise ValueError( 'Ambiguous CRS/SRID values: %s and %s' % (meta_srid, crs_srid) ) srid = meta_srid or crs_srid # TODO: add tests for CRS input if srid is not None: # Prepend the SRID result = 'SRID=%s;%s' % (srid, result) return result
[ "def", "dumps", "(", "obj", ",", "decimals", "=", "16", ")", ":", "try", ":", "geom_type", "=", "obj", "[", "'type'", "]", "exporter", "=", "_dumps_registry", ".", "get", "(", "geom_type", ")", "if", "exporter", "is", "None", ":", "_unsupported_geom_type", "(", "geom_type", ")", "# Check for empty cases", "if", "geom_type", "==", "'GeometryCollection'", ":", "if", "len", "(", "obj", "[", "'geometries'", "]", ")", "==", "0", ":", "return", "'GEOMETRYCOLLECTION EMPTY'", "else", ":", "# Geom has no coordinate values at all, and must be empty.", "if", "len", "(", "list", "(", "util", ".", "flatten_multi_dim", "(", "obj", "[", "'coordinates'", "]", ")", ")", ")", "==", "0", ":", "return", "'%s EMPTY'", "%", "geom_type", ".", "upper", "(", ")", "except", "KeyError", ":", "raise", "geomet", ".", "InvalidGeoJSONException", "(", "'Invalid GeoJSON: %s'", "%", "obj", ")", "result", "=", "exporter", "(", "obj", ",", "decimals", ")", "# Try to get the SRID from `meta.srid`", "meta_srid", "=", "obj", ".", "get", "(", "'meta'", ",", "{", "}", ")", ".", "get", "(", "'srid'", ")", "# Also try to get it from `crs.properties.name`:", "crs_srid", "=", "obj", ".", "get", "(", "'crs'", ",", "{", "}", ")", ".", "get", "(", "'properties'", ",", "{", "}", ")", ".", "get", "(", "'name'", ")", "if", "crs_srid", "is", "not", "None", ":", "# Shave off the EPSG prefix to give us the SRID:", "crs_srid", "=", "crs_srid", ".", "replace", "(", "'EPSG'", ",", "''", ")", "if", "(", "meta_srid", "is", "not", "None", "and", "crs_srid", "is", "not", "None", "and", "str", "(", "meta_srid", ")", "!=", "str", "(", "crs_srid", ")", ")", ":", "raise", "ValueError", "(", "'Ambiguous CRS/SRID values: %s and %s'", "%", "(", "meta_srid", ",", "crs_srid", ")", ")", "srid", "=", "meta_srid", "or", "crs_srid", "# TODO: add tests for CRS input", "if", "srid", "is", "not", "None", ":", "# Prepend the SRID", "result", "=", "'SRID=%s;%s'", "%", "(", "srid", ",", "result", ")", "return", "result" ]
Dump a GeoJSON-like `dict` to a WKT string.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "WKT", "string", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L57-L100
geomet/geomet
geomet/wkt.py
loads
def loads(string): """ Construct a GeoJSON `dict` from WKT (`string`). """ sio = StringIO.StringIO(string) # NOTE: This is not the intended purpose of `tokenize`, but it works. tokens = (x[1] for x in tokenize.generate_tokens(sio.readline)) tokens = _tokenize_wkt(tokens) geom_type_or_srid = next(tokens) srid = None geom_type = geom_type_or_srid if geom_type_or_srid == 'SRID': # The geometry WKT contains an SRID header. _assert_next_token(tokens, '=') srid = int(next(tokens)) _assert_next_token(tokens, ';') # We expected the geometry type to be next: geom_type = next(tokens) else: geom_type = geom_type_or_srid importer = _loads_registry.get(geom_type) if importer is None: _unsupported_geom_type(geom_type) peek = six.advance_iterator(tokens) if peek == 'EMPTY': if geom_type == 'GEOMETRYCOLLECTION': return dict(type='GeometryCollection', geometries=[]) else: return dict(type=_type_map_caps_to_mixed[geom_type], coordinates=[]) # Put the peeked element back on the head of the token generator tokens = itertools.chain([peek], tokens) result = importer(tokens, string) if srid is not None: result['meta'] = dict(srid=srid) return result
python
def loads(string): """ Construct a GeoJSON `dict` from WKT (`string`). """ sio = StringIO.StringIO(string) # NOTE: This is not the intended purpose of `tokenize`, but it works. tokens = (x[1] for x in tokenize.generate_tokens(sio.readline)) tokens = _tokenize_wkt(tokens) geom_type_or_srid = next(tokens) srid = None geom_type = geom_type_or_srid if geom_type_or_srid == 'SRID': # The geometry WKT contains an SRID header. _assert_next_token(tokens, '=') srid = int(next(tokens)) _assert_next_token(tokens, ';') # We expected the geometry type to be next: geom_type = next(tokens) else: geom_type = geom_type_or_srid importer = _loads_registry.get(geom_type) if importer is None: _unsupported_geom_type(geom_type) peek = six.advance_iterator(tokens) if peek == 'EMPTY': if geom_type == 'GEOMETRYCOLLECTION': return dict(type='GeometryCollection', geometries=[]) else: return dict(type=_type_map_caps_to_mixed[geom_type], coordinates=[]) # Put the peeked element back on the head of the token generator tokens = itertools.chain([peek], tokens) result = importer(tokens, string) if srid is not None: result['meta'] = dict(srid=srid) return result
[ "def", "loads", "(", "string", ")", ":", "sio", "=", "StringIO", ".", "StringIO", "(", "string", ")", "# NOTE: This is not the intended purpose of `tokenize`, but it works.", "tokens", "=", "(", "x", "[", "1", "]", "for", "x", "in", "tokenize", ".", "generate_tokens", "(", "sio", ".", "readline", ")", ")", "tokens", "=", "_tokenize_wkt", "(", "tokens", ")", "geom_type_or_srid", "=", "next", "(", "tokens", ")", "srid", "=", "None", "geom_type", "=", "geom_type_or_srid", "if", "geom_type_or_srid", "==", "'SRID'", ":", "# The geometry WKT contains an SRID header.", "_assert_next_token", "(", "tokens", ",", "'='", ")", "srid", "=", "int", "(", "next", "(", "tokens", ")", ")", "_assert_next_token", "(", "tokens", ",", "';'", ")", "# We expected the geometry type to be next:", "geom_type", "=", "next", "(", "tokens", ")", "else", ":", "geom_type", "=", "geom_type_or_srid", "importer", "=", "_loads_registry", ".", "get", "(", "geom_type", ")", "if", "importer", "is", "None", ":", "_unsupported_geom_type", "(", "geom_type", ")", "peek", "=", "six", ".", "advance_iterator", "(", "tokens", ")", "if", "peek", "==", "'EMPTY'", ":", "if", "geom_type", "==", "'GEOMETRYCOLLECTION'", ":", "return", "dict", "(", "type", "=", "'GeometryCollection'", ",", "geometries", "=", "[", "]", ")", "else", ":", "return", "dict", "(", "type", "=", "_type_map_caps_to_mixed", "[", "geom_type", "]", ",", "coordinates", "=", "[", "]", ")", "# Put the peeked element back on the head of the token generator", "tokens", "=", "itertools", ".", "chain", "(", "[", "peek", "]", ",", "tokens", ")", "result", "=", "importer", "(", "tokens", ",", "string", ")", "if", "srid", "is", "not", "None", ":", "result", "[", "'meta'", "]", "=", "dict", "(", "srid", "=", "srid", ")", "return", "result" ]
Construct a GeoJSON `dict` from WKT (`string`).
[ "Construct", "a", "GeoJSON", "dict", "from", "WKT", "(", "string", ")", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L111-L150
geomet/geomet
geomet/wkt.py
_tokenize_wkt
def _tokenize_wkt(tokens): """ Since the tokenizer treats "-" and numeric strings as separate values, combine them and yield them as a single token. This utility encapsulates parsing of negative numeric values from WKT can be used generically in all parsers. """ negative = False for t in tokens: if t == '-': negative = True continue else: if negative: yield '-%s' % t else: yield t negative = False
python
def _tokenize_wkt(tokens): """ Since the tokenizer treats "-" and numeric strings as separate values, combine them and yield them as a single token. This utility encapsulates parsing of negative numeric values from WKT can be used generically in all parsers. """ negative = False for t in tokens: if t == '-': negative = True continue else: if negative: yield '-%s' % t else: yield t negative = False
[ "def", "_tokenize_wkt", "(", "tokens", ")", ":", "negative", "=", "False", "for", "t", "in", "tokens", ":", "if", "t", "==", "'-'", ":", "negative", "=", "True", "continue", "else", ":", "if", "negative", ":", "yield", "'-%s'", "%", "t", "else", ":", "yield", "t", "negative", "=", "False" ]
Since the tokenizer treats "-" and numeric strings as separate values, combine them and yield them as a single token. This utility encapsulates parsing of negative numeric values from WKT can be used generically in all parsers.
[ "Since", "the", "tokenizer", "treats", "-", "and", "numeric", "strings", "as", "separate", "values", "combine", "them", "and", "yield", "them", "as", "a", "single", "token", ".", "This", "utility", "encapsulates", "parsing", "of", "negative", "numeric", "values", "from", "WKT", "can", "be", "used", "generically", "in", "all", "parsers", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L153-L170
geomet/geomet
geomet/wkt.py
_round_and_pad
def _round_and_pad(value, decimals): """ Round the input value to `decimals` places, and pad with 0's if the resulting value is less than `decimals`. :param value: The value to round :param decimals: Number of decimals places which should be displayed after the rounding. :return: str of the rounded value """ if isinstance(value, int) and decimals != 0: # if we get an int coordinate and we have a non-zero value for # `decimals`, we want to create a float to pad out. value = float(value) elif decimals == 0: # if get a `decimals` value of 0, we want to return an int. return repr(int(round(value, decimals))) rounded = repr(round(value, decimals)) rounded += '0' * (decimals - len(rounded.split('.')[1])) return rounded
python
def _round_and_pad(value, decimals): """ Round the input value to `decimals` places, and pad with 0's if the resulting value is less than `decimals`. :param value: The value to round :param decimals: Number of decimals places which should be displayed after the rounding. :return: str of the rounded value """ if isinstance(value, int) and decimals != 0: # if we get an int coordinate and we have a non-zero value for # `decimals`, we want to create a float to pad out. value = float(value) elif decimals == 0: # if get a `decimals` value of 0, we want to return an int. return repr(int(round(value, decimals))) rounded = repr(round(value, decimals)) rounded += '0' * (decimals - len(rounded.split('.')[1])) return rounded
[ "def", "_round_and_pad", "(", "value", ",", "decimals", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", "and", "decimals", "!=", "0", ":", "# if we get an int coordinate and we have a non-zero value for", "# `decimals`, we want to create a float to pad out.", "value", "=", "float", "(", "value", ")", "elif", "decimals", "==", "0", ":", "# if get a `decimals` value of 0, we want to return an int.", "return", "repr", "(", "int", "(", "round", "(", "value", ",", "decimals", ")", ")", ")", "rounded", "=", "repr", "(", "round", "(", "value", ",", "decimals", ")", ")", "rounded", "+=", "'0'", "*", "(", "decimals", "-", "len", "(", "rounded", ".", "split", "(", "'.'", ")", "[", "1", "]", ")", ")", "return", "rounded" ]
Round the input value to `decimals` places, and pad with 0's if the resulting value is less than `decimals`. :param value: The value to round :param decimals: Number of decimals places which should be displayed after the rounding. :return: str of the rounded value
[ "Round", "the", "input", "value", "to", "decimals", "places", "and", "pad", "with", "0", "s", "if", "the", "resulting", "value", "is", "less", "than", "decimals", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L177-L200
geomet/geomet
geomet/wkt.py
_dump_point
def _dump_point(obj, decimals): """ Dump a GeoJSON-like Point object to WKT. :param dict obj: A GeoJSON-like `dict` representing a Point. :param int decimals: int which indicates the number of digits to display after the decimal point when formatting coordinates. :returns: WKT representation of the input GeoJSON Point ``obj``. """ coords = obj['coordinates'] pt = 'POINT (%s)' % ' '.join(_round_and_pad(c, decimals) for c in coords) return pt
python
def _dump_point(obj, decimals): """ Dump a GeoJSON-like Point object to WKT. :param dict obj: A GeoJSON-like `dict` representing a Point. :param int decimals: int which indicates the number of digits to display after the decimal point when formatting coordinates. :returns: WKT representation of the input GeoJSON Point ``obj``. """ coords = obj['coordinates'] pt = 'POINT (%s)' % ' '.join(_round_and_pad(c, decimals) for c in coords) return pt
[ "def", "_dump_point", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "pt", "=", "'POINT (%s)'", "%", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "coords", ")", "return", "pt" ]
Dump a GeoJSON-like Point object to WKT. :param dict obj: A GeoJSON-like `dict` representing a Point. :param int decimals: int which indicates the number of digits to display after the decimal point when formatting coordinates. :returns: WKT representation of the input GeoJSON Point ``obj``.
[ "Dump", "a", "GeoJSON", "-", "like", "Point", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L203-L219
geomet/geomet
geomet/wkt.py
_dump_linestring
def _dump_linestring(obj, decimals): """ Dump a GeoJSON-like LineString object to WKT. Input parameters and return value are the LINESTRING equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] ls = 'LINESTRING (%s)' ls %= ', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in coords) return ls
python
def _dump_linestring(obj, decimals): """ Dump a GeoJSON-like LineString object to WKT. Input parameters and return value are the LINESTRING equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] ls = 'LINESTRING (%s)' ls %= ', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in coords) return ls
[ "def", "_dump_linestring", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "ls", "=", "'LINESTRING (%s)'", "ls", "%=", "', '", ".", "join", "(", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "pt", ")", "for", "pt", "in", "coords", ")", "return", "ls" ]
Dump a GeoJSON-like LineString object to WKT. Input parameters and return value are the LINESTRING equivalent to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "LineString", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L222-L233
geomet/geomet
geomet/wkt.py
_dump_polygon
def _dump_polygon(obj, decimals): """ Dump a GeoJSON-like Polygon object to WKT. Input parameters and return value are the POLYGON equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] poly = 'POLYGON (%s)' rings = (', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in ring) for ring in coords) rings = ('(%s)' % r for r in rings) poly %= ', '.join(rings) return poly
python
def _dump_polygon(obj, decimals): """ Dump a GeoJSON-like Polygon object to WKT. Input parameters and return value are the POLYGON equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] poly = 'POLYGON (%s)' rings = (', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in ring) for ring in coords) rings = ('(%s)' % r for r in rings) poly %= ', '.join(rings) return poly
[ "def", "_dump_polygon", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "poly", "=", "'POLYGON (%s)'", "rings", "=", "(", "', '", ".", "join", "(", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "pt", ")", "for", "pt", "in", "ring", ")", "for", "ring", "in", "coords", ")", "rings", "=", "(", "'(%s)'", "%", "r", "for", "r", "in", "rings", ")", "poly", "%=", "', '", ".", "join", "(", "rings", ")", "return", "poly" ]
Dump a GeoJSON-like Polygon object to WKT. Input parameters and return value are the POLYGON equivalent to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "Polygon", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L236-L250
geomet/geomet
geomet/wkt.py
_dump_multipoint
def _dump_multipoint(obj, decimals): """ Dump a GeoJSON-like MultiPoint object to WKT. Input parameters and return value are the MULTIPOINT equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mp = 'MULTIPOINT (%s)' points = (' '.join(_round_and_pad(c, decimals) for c in pt) for pt in coords) # Add parens around each point. points = ('(%s)' % pt for pt in points) mp %= ', '.join(points) return mp
python
def _dump_multipoint(obj, decimals): """ Dump a GeoJSON-like MultiPoint object to WKT. Input parameters and return value are the MULTIPOINT equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mp = 'MULTIPOINT (%s)' points = (' '.join(_round_and_pad(c, decimals) for c in pt) for pt in coords) # Add parens around each point. points = ('(%s)' % pt for pt in points) mp %= ', '.join(points) return mp
[ "def", "_dump_multipoint", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "mp", "=", "'MULTIPOINT (%s)'", "points", "=", "(", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "pt", ")", "for", "pt", "in", "coords", ")", "# Add parens around each point.", "points", "=", "(", "'(%s)'", "%", "pt", "for", "pt", "in", "points", ")", "mp", "%=", "', '", ".", "join", "(", "points", ")", "return", "mp" ]
Dump a GeoJSON-like MultiPoint object to WKT. Input parameters and return value are the MULTIPOINT equivalent to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "MultiPoint", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L253-L267
geomet/geomet
geomet/wkt.py
_dump_multilinestring
def _dump_multilinestring(obj, decimals): """ Dump a GeoJSON-like MultiLineString object to WKT. Input parameters and return value are the MULTILINESTRING equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mlls = 'MULTILINESTRING (%s)' linestrs = ('(%s)' % ', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in linestr) for linestr in coords) mlls %= ', '.join(ls for ls in linestrs) return mlls
python
def _dump_multilinestring(obj, decimals): """ Dump a GeoJSON-like MultiLineString object to WKT. Input parameters and return value are the MULTILINESTRING equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mlls = 'MULTILINESTRING (%s)' linestrs = ('(%s)' % ', '.join(' '.join(_round_and_pad(c, decimals) for c in pt) for pt in linestr) for linestr in coords) mlls %= ', '.join(ls for ls in linestrs) return mlls
[ "def", "_dump_multilinestring", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "mlls", "=", "'MULTILINESTRING (%s)'", "linestrs", "=", "(", "'(%s)'", "%", "', '", ".", "join", "(", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "pt", ")", "for", "pt", "in", "linestr", ")", "for", "linestr", "in", "coords", ")", "mlls", "%=", "', '", ".", "join", "(", "ls", "for", "ls", "in", "linestrs", ")", "return", "mlls" ]
Dump a GeoJSON-like MultiLineString object to WKT. Input parameters and return value are the MULTILINESTRING equivalent to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "MultiLineString", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L270-L282
geomet/geomet
geomet/wkt.py
_dump_multipolygon
def _dump_multipolygon(obj, decimals): """ Dump a GeoJSON-like MultiPolygon object to WKT. Input parameters and return value are the MULTIPOLYGON equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mp = 'MULTIPOLYGON (%s)' polys = ( # join the polygons in the multipolygon ', '.join( # join the rings in a polygon, # and wrap in parens '(%s)' % ', '.join( # join the points in a ring, # and wrap in parens '(%s)' % ', '.join( # join coordinate values of a vertex ' '.join(_round_and_pad(c, decimals) for c in pt) for pt in ring) for ring in poly) for poly in coords) ) mp %= polys return mp
python
def _dump_multipolygon(obj, decimals): """ Dump a GeoJSON-like MultiPolygon object to WKT. Input parameters and return value are the MULTIPOLYGON equivalent to :func:`_dump_point`. """ coords = obj['coordinates'] mp = 'MULTIPOLYGON (%s)' polys = ( # join the polygons in the multipolygon ', '.join( # join the rings in a polygon, # and wrap in parens '(%s)' % ', '.join( # join the points in a ring, # and wrap in parens '(%s)' % ', '.join( # join coordinate values of a vertex ' '.join(_round_and_pad(c, decimals) for c in pt) for pt in ring) for ring in poly) for poly in coords) ) mp %= polys return mp
[ "def", "_dump_multipolygon", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "mp", "=", "'MULTIPOLYGON (%s)'", "polys", "=", "(", "# join the polygons in the multipolygon", "', '", ".", "join", "(", "# join the rings in a polygon,", "# and wrap in parens", "'(%s)'", "%", "', '", ".", "join", "(", "# join the points in a ring,", "# and wrap in parens", "'(%s)'", "%", "', '", ".", "join", "(", "# join coordinate values of a vertex", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "pt", ")", "for", "pt", "in", "ring", ")", "for", "ring", "in", "poly", ")", "for", "poly", "in", "coords", ")", ")", "mp", "%=", "polys", "return", "mp" ]
Dump a GeoJSON-like MultiPolygon object to WKT. Input parameters and return value are the MULTIPOLYGON equivalent to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "MultiPolygon", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L285-L311
geomet/geomet
geomet/wkt.py
_dump_geometrycollection
def _dump_geometrycollection(obj, decimals): """ Dump a GeoJSON-like GeometryCollection object to WKT. Input parameters and return value are the GEOMETRYCOLLECTION equivalent to :func:`_dump_point`. The WKT conversions for each geometry in the collection are delegated to their respective functions. """ gc = 'GEOMETRYCOLLECTION (%s)' geoms = obj['geometries'] geoms_wkt = [] for geom in geoms: geom_type = geom['type'] geoms_wkt.append(_dumps_registry.get(geom_type)(geom, decimals)) gc %= ','.join(geoms_wkt) return gc
python
def _dump_geometrycollection(obj, decimals): """ Dump a GeoJSON-like GeometryCollection object to WKT. Input parameters and return value are the GEOMETRYCOLLECTION equivalent to :func:`_dump_point`. The WKT conversions for each geometry in the collection are delegated to their respective functions. """ gc = 'GEOMETRYCOLLECTION (%s)' geoms = obj['geometries'] geoms_wkt = [] for geom in geoms: geom_type = geom['type'] geoms_wkt.append(_dumps_registry.get(geom_type)(geom, decimals)) gc %= ','.join(geoms_wkt) return gc
[ "def", "_dump_geometrycollection", "(", "obj", ",", "decimals", ")", ":", "gc", "=", "'GEOMETRYCOLLECTION (%s)'", "geoms", "=", "obj", "[", "'geometries'", "]", "geoms_wkt", "=", "[", "]", "for", "geom", "in", "geoms", ":", "geom_type", "=", "geom", "[", "'type'", "]", "geoms_wkt", ".", "append", "(", "_dumps_registry", ".", "get", "(", "geom_type", ")", "(", "geom", ",", "decimals", ")", ")", "gc", "%=", "','", ".", "join", "(", "geoms_wkt", ")", "return", "gc" ]
Dump a GeoJSON-like GeometryCollection object to WKT. Input parameters and return value are the GEOMETRYCOLLECTION equivalent to :func:`_dump_point`. The WKT conversions for each geometry in the collection are delegated to their respective functions.
[ "Dump", "a", "GeoJSON", "-", "like", "GeometryCollection", "object", "to", "WKT", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L314-L331
geomet/geomet
geomet/wkt.py
_load_point
def _load_point(tokens, string): """ :param tokens: A generator of string tokens for the input WKT, begining just after the geometry type. The geometry type is consumed before we get to here. For example, if :func:`loads` is called with the input 'POINT(0.0 1.0)', ``tokens`` would generate the following values: .. code-block:: python ['(', '0.0', '1.0', ')'] :param str string: The original WKT string. :returns: A GeoJSON `dict` Point representation of the WKT ``string``. """ if not next(tokens) == '(': raise ValueError(INVALID_WKT_FMT % string) coords = [] try: for t in tokens: if t == ')': break else: coords.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='Point', coordinates=coords)
python
def _load_point(tokens, string): """ :param tokens: A generator of string tokens for the input WKT, begining just after the geometry type. The geometry type is consumed before we get to here. For example, if :func:`loads` is called with the input 'POINT(0.0 1.0)', ``tokens`` would generate the following values: .. code-block:: python ['(', '0.0', '1.0', ')'] :param str string: The original WKT string. :returns: A GeoJSON `dict` Point representation of the WKT ``string``. """ if not next(tokens) == '(': raise ValueError(INVALID_WKT_FMT % string) coords = [] try: for t in tokens: if t == ')': break else: coords.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='Point', coordinates=coords)
[ "def", "_load_point", "(", "tokens", ",", "string", ")", ":", "if", "not", "next", "(", "tokens", ")", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "coords", "=", "[", "]", "try", ":", "for", "t", "in", "tokens", ":", "if", "t", "==", "')'", ":", "break", "else", ":", "coords", ".", "append", "(", "float", "(", "t", ")", ")", "except", "tokenize", ".", "TokenError", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "dict", "(", "type", "=", "'Point'", ",", "coordinates", "=", "coords", ")" ]
:param tokens: A generator of string tokens for the input WKT, begining just after the geometry type. The geometry type is consumed before we get to here. For example, if :func:`loads` is called with the input 'POINT(0.0 1.0)', ``tokens`` would generate the following values: .. code-block:: python ['(', '0.0', '1.0', ')'] :param str string: The original WKT string. :returns: A GeoJSON `dict` Point representation of the WKT ``string``.
[ ":", "param", "tokens", ":", "A", "generator", "of", "string", "tokens", "for", "the", "input", "WKT", "begining", "just", "after", "the", "geometry", "type", ".", "The", "geometry", "type", "is", "consumed", "before", "we", "get", "to", "here", ".", "For", "example", "if", ":", "func", ":", "loads", "is", "called", "with", "the", "input", "POINT", "(", "0", ".", "0", "1", ".", "0", ")", "tokens", "would", "generate", "the", "following", "values", ":" ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L334-L363
geomet/geomet
geomet/wkt.py
_load_linestring
def _load_linestring(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling LINESTRING geometry. :returns: A GeoJSON `dict` LineString representation of the WKT ``string``. """ if not next(tokens) == '(': raise ValueError(INVALID_WKT_FMT % string) # a list of lists # each member list represents a point coords = [] try: pt = [] for t in tokens: if t == ')': coords.append(pt) break elif t == ',': # it's the end of the point coords.append(pt) pt = [] else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='LineString', coordinates=coords)
python
def _load_linestring(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling LINESTRING geometry. :returns: A GeoJSON `dict` LineString representation of the WKT ``string``. """ if not next(tokens) == '(': raise ValueError(INVALID_WKT_FMT % string) # a list of lists # each member list represents a point coords = [] try: pt = [] for t in tokens: if t == ')': coords.append(pt) break elif t == ',': # it's the end of the point coords.append(pt) pt = [] else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='LineString', coordinates=coords)
[ "def", "_load_linestring", "(", "tokens", ",", "string", ")", ":", "if", "not", "next", "(", "tokens", ")", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "# a list of lists", "# each member list represents a point", "coords", "=", "[", "]", "try", ":", "pt", "=", "[", "]", "for", "t", "in", "tokens", ":", "if", "t", "==", "')'", ":", "coords", ".", "append", "(", "pt", ")", "break", "elif", "t", "==", "','", ":", "# it's the end of the point", "coords", ".", "append", "(", "pt", ")", "pt", "=", "[", "]", "else", ":", "pt", ".", "append", "(", "float", "(", "t", ")", ")", "except", "tokenize", ".", "TokenError", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "dict", "(", "type", "=", "'LineString'", ",", "coordinates", "=", "coords", ")" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling LINESTRING geometry. :returns: A GeoJSON `dict` LineString representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "LINESTRING", "geometry", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L366-L395
geomet/geomet
geomet/wkt.py
_load_polygon
def _load_polygon(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling POLYGON geometry. :returns: A GeoJSON `dict` Polygon representation of the WKT ``string``. """ open_parens = next(tokens), next(tokens) if not open_parens == ('(', '('): raise ValueError(INVALID_WKT_FMT % string) # coords contains a list of rings # each ring contains a list of points # each point is a list of 2-4 values coords = [] ring = [] on_ring = True try: pt = [] for t in tokens: if t == ')' and on_ring: # The ring is finished ring.append(pt) coords.append(ring) on_ring = False elif t == ')' and not on_ring: # it's the end of the polygon break elif t == '(': # it's a new ring ring = [] pt = [] on_ring = True elif t == ',' and on_ring: # it's the end of a point ring.append(pt) pt = [] elif t == ',' and not on_ring: # there's another ring. # do nothing pass else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='Polygon', coordinates=coords)
python
def _load_polygon(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling POLYGON geometry. :returns: A GeoJSON `dict` Polygon representation of the WKT ``string``. """ open_parens = next(tokens), next(tokens) if not open_parens == ('(', '('): raise ValueError(INVALID_WKT_FMT % string) # coords contains a list of rings # each ring contains a list of points # each point is a list of 2-4 values coords = [] ring = [] on_ring = True try: pt = [] for t in tokens: if t == ')' and on_ring: # The ring is finished ring.append(pt) coords.append(ring) on_ring = False elif t == ')' and not on_ring: # it's the end of the polygon break elif t == '(': # it's a new ring ring = [] pt = [] on_ring = True elif t == ',' and on_ring: # it's the end of a point ring.append(pt) pt = [] elif t == ',' and not on_ring: # there's another ring. # do nothing pass else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) return dict(type='Polygon', coordinates=coords)
[ "def", "_load_polygon", "(", "tokens", ",", "string", ")", ":", "open_parens", "=", "next", "(", "tokens", ")", ",", "next", "(", "tokens", ")", "if", "not", "open_parens", "==", "(", "'('", ",", "'('", ")", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "# coords contains a list of rings", "# each ring contains a list of points", "# each point is a list of 2-4 values", "coords", "=", "[", "]", "ring", "=", "[", "]", "on_ring", "=", "True", "try", ":", "pt", "=", "[", "]", "for", "t", "in", "tokens", ":", "if", "t", "==", "')'", "and", "on_ring", ":", "# The ring is finished", "ring", ".", "append", "(", "pt", ")", "coords", ".", "append", "(", "ring", ")", "on_ring", "=", "False", "elif", "t", "==", "')'", "and", "not", "on_ring", ":", "# it's the end of the polygon", "break", "elif", "t", "==", "'('", ":", "# it's a new ring", "ring", "=", "[", "]", "pt", "=", "[", "]", "on_ring", "=", "True", "elif", "t", "==", "','", "and", "on_ring", ":", "# it's the end of a point", "ring", ".", "append", "(", "pt", ")", "pt", "=", "[", "]", "elif", "t", "==", "','", "and", "not", "on_ring", ":", "# there's another ring.", "# do nothing", "pass", "else", ":", "pt", ".", "append", "(", "float", "(", "t", ")", ")", "except", "tokenize", ".", "TokenError", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "dict", "(", "type", "=", "'Polygon'", ",", "coordinates", "=", "coords", ")" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling POLYGON geometry. :returns: A GeoJSON `dict` Polygon representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "POLYGON", "geometry", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L398-L446
geomet/geomet
geomet/wkt.py
_load_multipoint
def _load_multipoint(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOINT geometry. :returns: A GeoJSON `dict` MultiPoint representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) coords = [] pt = [] paren_depth = 1 try: for t in tokens: if t == '(': paren_depth += 1 elif t == ')': paren_depth -= 1 if paren_depth == 0: break elif t == '': pass elif t == ',': # the point is done coords.append(pt) pt = [] else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) # Given the way we're parsing, we'll probably have to deal with the last # point after the loop if len(pt) > 0: coords.append(pt) return dict(type='MultiPoint', coordinates=coords)
python
def _load_multipoint(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOINT geometry. :returns: A GeoJSON `dict` MultiPoint representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) coords = [] pt = [] paren_depth = 1 try: for t in tokens: if t == '(': paren_depth += 1 elif t == ')': paren_depth -= 1 if paren_depth == 0: break elif t == '': pass elif t == ',': # the point is done coords.append(pt) pt = [] else: pt.append(float(t)) except tokenize.TokenError: raise ValueError(INVALID_WKT_FMT % string) # Given the way we're parsing, we'll probably have to deal with the last # point after the loop if len(pt) > 0: coords.append(pt) return dict(type='MultiPoint', coordinates=coords)
[ "def", "_load_multipoint", "(", "tokens", ",", "string", ")", ":", "open_paren", "=", "next", "(", "tokens", ")", "if", "not", "open_paren", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "coords", "=", "[", "]", "pt", "=", "[", "]", "paren_depth", "=", "1", "try", ":", "for", "t", "in", "tokens", ":", "if", "t", "==", "'('", ":", "paren_depth", "+=", "1", "elif", "t", "==", "')'", ":", "paren_depth", "-=", "1", "if", "paren_depth", "==", "0", ":", "break", "elif", "t", "==", "''", ":", "pass", "elif", "t", "==", "','", ":", "# the point is done", "coords", ".", "append", "(", "pt", ")", "pt", "=", "[", "]", "else", ":", "pt", ".", "append", "(", "float", "(", "t", ")", ")", "except", "tokenize", ".", "TokenError", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "# Given the way we're parsing, we'll probably have to deal with the last", "# point after the loop", "if", "len", "(", "pt", ")", ">", "0", ":", "coords", ".", "append", "(", "pt", ")", "return", "dict", "(", "type", "=", "'MultiPoint'", ",", "coordinates", "=", "coords", ")" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOINT geometry. :returns: A GeoJSON `dict` MultiPoint representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "MULTIPOINT", "geometry", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L449-L489
geomet/geomet
geomet/wkt.py
_load_multipolygon
def _load_multipolygon(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOLYGON geometry. :returns: A GeoJSON `dict` MultiPolygon representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) polygons = [] while True: try: poly = _load_polygon(tokens, string) polygons.append(poly['coordinates']) t = next(tokens) if t == ')': # we're done; no more polygons. break except StopIteration: # If we reach this, the WKT is not valid. raise ValueError(INVALID_WKT_FMT % string) return dict(type='MultiPolygon', coordinates=polygons)
python
def _load_multipolygon(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOLYGON geometry. :returns: A GeoJSON `dict` MultiPolygon representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) polygons = [] while True: try: poly = _load_polygon(tokens, string) polygons.append(poly['coordinates']) t = next(tokens) if t == ')': # we're done; no more polygons. break except StopIteration: # If we reach this, the WKT is not valid. raise ValueError(INVALID_WKT_FMT % string) return dict(type='MultiPolygon', coordinates=polygons)
[ "def", "_load_multipolygon", "(", "tokens", ",", "string", ")", ":", "open_paren", "=", "next", "(", "tokens", ")", "if", "not", "open_paren", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "polygons", "=", "[", "]", "while", "True", ":", "try", ":", "poly", "=", "_load_polygon", "(", "tokens", ",", "string", ")", "polygons", ".", "append", "(", "poly", "[", "'coordinates'", "]", ")", "t", "=", "next", "(", "tokens", ")", "if", "t", "==", "')'", ":", "# we're done; no more polygons.", "break", "except", "StopIteration", ":", "# If we reach this, the WKT is not valid.", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "dict", "(", "type", "=", "'MultiPolygon'", ",", "coordinates", "=", "polygons", ")" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTIPOLYGON geometry. :returns: A GeoJSON `dict` MultiPolygon representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "MULTIPOLYGON", "geometry", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L492-L517
geomet/geomet
geomet/wkt.py
_load_multilinestring
def _load_multilinestring(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTILINESTRING geometry. :returns: A GeoJSON `dict` MultiLineString representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) linestrs = [] while True: try: linestr = _load_linestring(tokens, string) linestrs.append(linestr['coordinates']) t = next(tokens) if t == ')': # we're done; no more linestrings. break except StopIteration: # If we reach this, the WKT is not valid. raise ValueError(INVALID_WKT_FMT % string) return dict(type='MultiLineString', coordinates=linestrs)
python
def _load_multilinestring(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTILINESTRING geometry. :returns: A GeoJSON `dict` MultiLineString representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) linestrs = [] while True: try: linestr = _load_linestring(tokens, string) linestrs.append(linestr['coordinates']) t = next(tokens) if t == ')': # we're done; no more linestrings. break except StopIteration: # If we reach this, the WKT is not valid. raise ValueError(INVALID_WKT_FMT % string) return dict(type='MultiLineString', coordinates=linestrs)
[ "def", "_load_multilinestring", "(", "tokens", ",", "string", ")", ":", "open_paren", "=", "next", "(", "tokens", ")", "if", "not", "open_paren", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "linestrs", "=", "[", "]", "while", "True", ":", "try", ":", "linestr", "=", "_load_linestring", "(", "tokens", ",", "string", ")", "linestrs", ".", "append", "(", "linestr", "[", "'coordinates'", "]", ")", "t", "=", "next", "(", "tokens", ")", "if", "t", "==", "')'", ":", "# we're done; no more linestrings.", "break", "except", "StopIteration", ":", "# If we reach this, the WKT is not valid.", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "dict", "(", "type", "=", "'MultiLineString'", ",", "coordinates", "=", "linestrs", ")" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling MULTILINESTRING geometry. :returns: A GeoJSON `dict` MultiLineString representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "MULTILINESTRING", "geometry", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L520-L545
geomet/geomet
geomet/wkt.py
_load_geometrycollection
def _load_geometrycollection(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling GEOMETRYCOLLECTIONs. Delegates parsing to the parsers for the individual geometry types. :returns: A GeoJSON `dict` GeometryCollection representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) geoms = [] result = dict(type='GeometryCollection', geometries=geoms) while True: try: t = next(tokens) if t == ')': break elif t == ',': # another geometry still continue else: geom_type = t load_func = _loads_registry.get(geom_type) geom = load_func(tokens, string) geoms.append(geom) except StopIteration: raise ValueError(INVALID_WKT_FMT % string) return result
python
def _load_geometrycollection(tokens, string): """ Has similar inputs and return value to to :func:`_load_point`, except is for handling GEOMETRYCOLLECTIONs. Delegates parsing to the parsers for the individual geometry types. :returns: A GeoJSON `dict` GeometryCollection representation of the WKT ``string``. """ open_paren = next(tokens) if not open_paren == '(': raise ValueError(INVALID_WKT_FMT % string) geoms = [] result = dict(type='GeometryCollection', geometries=geoms) while True: try: t = next(tokens) if t == ')': break elif t == ',': # another geometry still continue else: geom_type = t load_func = _loads_registry.get(geom_type) geom = load_func(tokens, string) geoms.append(geom) except StopIteration: raise ValueError(INVALID_WKT_FMT % string) return result
[ "def", "_load_geometrycollection", "(", "tokens", ",", "string", ")", ":", "open_paren", "=", "next", "(", "tokens", ")", "if", "not", "open_paren", "==", "'('", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "geoms", "=", "[", "]", "result", "=", "dict", "(", "type", "=", "'GeometryCollection'", ",", "geometries", "=", "geoms", ")", "while", "True", ":", "try", ":", "t", "=", "next", "(", "tokens", ")", "if", "t", "==", "')'", ":", "break", "elif", "t", "==", "','", ":", "# another geometry still", "continue", "else", ":", "geom_type", "=", "t", "load_func", "=", "_loads_registry", ".", "get", "(", "geom_type", ")", "geom", "=", "load_func", "(", "tokens", ",", "string", ")", "geoms", ".", "append", "(", "geom", ")", "except", "StopIteration", ":", "raise", "ValueError", "(", "INVALID_WKT_FMT", "%", "string", ")", "return", "result" ]
Has similar inputs and return value to to :func:`_load_point`, except is for handling GEOMETRYCOLLECTIONs. Delegates parsing to the parsers for the individual geometry types. :returns: A GeoJSON `dict` GeometryCollection representation of the WKT ``string``.
[ "Has", "similar", "inputs", "and", "return", "value", "to", "to", ":", "func", ":", "_load_point", "except", "is", "for", "handling", "GEOMETRYCOLLECTIONs", "." ]
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L548-L580
yola/demands
demands/__init__.py
HTTPServiceClient._get_request_params
def _get_request_params(self, **kwargs): """Merge shared params and new params.""" request_params = copy.deepcopy(self._shared_request_params) for key, value in iteritems(kwargs): if isinstance(value, dict) and key in request_params: # ensure we don't lose dict values like headers or cookies request_params[key].update(value) else: request_params[key] = value return request_params
python
def _get_request_params(self, **kwargs): """Merge shared params and new params.""" request_params = copy.deepcopy(self._shared_request_params) for key, value in iteritems(kwargs): if isinstance(value, dict) and key in request_params: # ensure we don't lose dict values like headers or cookies request_params[key].update(value) else: request_params[key] = value return request_params
[ "def", "_get_request_params", "(", "self", ",", "*", "*", "kwargs", ")", ":", "request_params", "=", "copy", ".", "deepcopy", "(", "self", ".", "_shared_request_params", ")", "for", "key", ",", "value", "in", "iteritems", "(", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", "and", "key", "in", "request_params", ":", "# ensure we don't lose dict values like headers or cookies", "request_params", "[", "key", "]", ".", "update", "(", "value", ")", "else", ":", "request_params", "[", "key", "]", "=", "value", "return", "request_params" ]
Merge shared params and new params.
[ "Merge", "shared", "params", "and", "new", "params", "." ]
train
https://github.com/yola/demands/blob/816ae4a2684f077f5bb555844ee5f14228b20dba/demands/__init__.py#L66-L75
yola/demands
demands/__init__.py
HTTPServiceClient._sanitize_request_params
def _sanitize_request_params(self, request_params): """Remove keyword arguments not used by `requests`""" if 'verify_ssl' in request_params: request_params['verify'] = request_params.pop('verify_ssl') return dict((key, val) for key, val in request_params.items() if key in self._VALID_REQUEST_ARGS)
python
def _sanitize_request_params(self, request_params): """Remove keyword arguments not used by `requests`""" if 'verify_ssl' in request_params: request_params['verify'] = request_params.pop('verify_ssl') return dict((key, val) for key, val in request_params.items() if key in self._VALID_REQUEST_ARGS)
[ "def", "_sanitize_request_params", "(", "self", ",", "request_params", ")", ":", "if", "'verify_ssl'", "in", "request_params", ":", "request_params", "[", "'verify'", "]", "=", "request_params", ".", "pop", "(", "'verify_ssl'", ")", "return", "dict", "(", "(", "key", ",", "val", ")", "for", "key", ",", "val", "in", "request_params", ".", "items", "(", ")", "if", "key", "in", "self", ".", "_VALID_REQUEST_ARGS", ")" ]
Remove keyword arguments not used by `requests`
[ "Remove", "keyword", "arguments", "not", "used", "by", "requests" ]
train
https://github.com/yola/demands/blob/816ae4a2684f077f5bb555844ee5f14228b20dba/demands/__init__.py#L77-L82
yola/demands
demands/__init__.py
HTTPServiceClient.request
def request(self, method, path, **kwargs): """Send a :class:`requests.Request` and demand a :class:`requests.Response` """ if path: url = '%s/%s' % (self.url.rstrip('/'), path.lstrip('/')) else: url = self.url request_params = self._get_request_params(method=method, url=url, **kwargs) request_params = self.pre_send(request_params) sanitized_params = self._sanitize_request_params(request_params) start_time = time.time() response = super(HTTPServiceClient, self).request(**sanitized_params) # Log request and params (without passwords) log.debug( '%s HTTP [%s] call to "%s" %.2fms', response.status_code, method, response.url, (time.time() - start_time) * 1000) auth = sanitized_params.pop('auth', None) log.debug('HTTP request params: %s', sanitized_params) if auth: log.debug('Authentication via HTTP auth as "%s"', auth[0]) response.is_ok = response.status_code < 300 if not self.is_acceptable(response, request_params): raise HTTPServiceError(response) response = self.post_send(response, **request_params) return response
python
def request(self, method, path, **kwargs): """Send a :class:`requests.Request` and demand a :class:`requests.Response` """ if path: url = '%s/%s' % (self.url.rstrip('/'), path.lstrip('/')) else: url = self.url request_params = self._get_request_params(method=method, url=url, **kwargs) request_params = self.pre_send(request_params) sanitized_params = self._sanitize_request_params(request_params) start_time = time.time() response = super(HTTPServiceClient, self).request(**sanitized_params) # Log request and params (without passwords) log.debug( '%s HTTP [%s] call to "%s" %.2fms', response.status_code, method, response.url, (time.time() - start_time) * 1000) auth = sanitized_params.pop('auth', None) log.debug('HTTP request params: %s', sanitized_params) if auth: log.debug('Authentication via HTTP auth as "%s"', auth[0]) response.is_ok = response.status_code < 300 if not self.is_acceptable(response, request_params): raise HTTPServiceError(response) response = self.post_send(response, **request_params) return response
[ "def", "request", "(", "self", ",", "method", ",", "path", ",", "*", "*", "kwargs", ")", ":", "if", "path", ":", "url", "=", "'%s/%s'", "%", "(", "self", ".", "url", ".", "rstrip", "(", "'/'", ")", ",", "path", ".", "lstrip", "(", "'/'", ")", ")", "else", ":", "url", "=", "self", ".", "url", "request_params", "=", "self", ".", "_get_request_params", "(", "method", "=", "method", ",", "url", "=", "url", ",", "*", "*", "kwargs", ")", "request_params", "=", "self", ".", "pre_send", "(", "request_params", ")", "sanitized_params", "=", "self", ".", "_sanitize_request_params", "(", "request_params", ")", "start_time", "=", "time", ".", "time", "(", ")", "response", "=", "super", "(", "HTTPServiceClient", ",", "self", ")", ".", "request", "(", "*", "*", "sanitized_params", ")", "# Log request and params (without passwords)", "log", ".", "debug", "(", "'%s HTTP [%s] call to \"%s\" %.2fms'", ",", "response", ".", "status_code", ",", "method", ",", "response", ".", "url", ",", "(", "time", ".", "time", "(", ")", "-", "start_time", ")", "*", "1000", ")", "auth", "=", "sanitized_params", ".", "pop", "(", "'auth'", ",", "None", ")", "log", ".", "debug", "(", "'HTTP request params: %s'", ",", "sanitized_params", ")", "if", "auth", ":", "log", ".", "debug", "(", "'Authentication via HTTP auth as \"%s\"'", ",", "auth", "[", "0", "]", ")", "response", ".", "is_ok", "=", "response", ".", "status_code", "<", "300", "if", "not", "self", ".", "is_acceptable", "(", "response", ",", "request_params", ")", ":", "raise", "HTTPServiceError", "(", "response", ")", "response", "=", "self", ".", "post_send", "(", "response", ",", "*", "*", "request_params", ")", "return", "response" ]
Send a :class:`requests.Request` and demand a :class:`requests.Response`
[ "Send", "a", ":", "class", ":", "requests", ".", "Request", "and", "demand", "a", ":", "class", ":", "requests", ".", "Response" ]
train
https://github.com/yola/demands/blob/816ae4a2684f077f5bb555844ee5f14228b20dba/demands/__init__.py#L84-L115
yola/demands
demands/__init__.py
HTTPServiceClient.pre_send
def pre_send(self, request_params): """Override this method to modify sent request parameters""" for adapter in itervalues(self.adapters): adapter.max_retries = request_params.get('max_retries', 0) return request_params
python
def pre_send(self, request_params): """Override this method to modify sent request parameters""" for adapter in itervalues(self.adapters): adapter.max_retries = request_params.get('max_retries', 0) return request_params
[ "def", "pre_send", "(", "self", ",", "request_params", ")", ":", "for", "adapter", "in", "itervalues", "(", "self", ".", "adapters", ")", ":", "adapter", ".", "max_retries", "=", "request_params", ".", "get", "(", "'max_retries'", ",", "0", ")", "return", "request_params" ]
Override this method to modify sent request parameters
[ "Override", "this", "method", "to", "modify", "sent", "request", "parameters" ]
train
https://github.com/yola/demands/blob/816ae4a2684f077f5bb555844ee5f14228b20dba/demands/__init__.py#L117-L122
yola/demands
demands/__init__.py
HTTPServiceClient.is_acceptable
def is_acceptable(self, response, request_params): """ Override this method to create a different definition of what kind of response is acceptable. If `bool(the_return_value) is False` then an `HTTPServiceError` will be raised. For example, you might want to assert that the body must be empty, so you could return `len(response.content) == 0`. In the default implementation, a response is acceptable if and only if the response code is either less than 300 (typically 200, i.e. OK) or if it is in the `expected_response_codes` parameter in the constructor. """ expected_codes = request_params.get('expected_response_codes', []) return response.is_ok or response.status_code in expected_codes
python
def is_acceptable(self, response, request_params): """ Override this method to create a different definition of what kind of response is acceptable. If `bool(the_return_value) is False` then an `HTTPServiceError` will be raised. For example, you might want to assert that the body must be empty, so you could return `len(response.content) == 0`. In the default implementation, a response is acceptable if and only if the response code is either less than 300 (typically 200, i.e. OK) or if it is in the `expected_response_codes` parameter in the constructor. """ expected_codes = request_params.get('expected_response_codes', []) return response.is_ok or response.status_code in expected_codes
[ "def", "is_acceptable", "(", "self", ",", "response", ",", "request_params", ")", ":", "expected_codes", "=", "request_params", ".", "get", "(", "'expected_response_codes'", ",", "[", "]", ")", "return", "response", ".", "is_ok", "or", "response", ".", "status_code", "in", "expected_codes" ]
Override this method to create a different definition of what kind of response is acceptable. If `bool(the_return_value) is False` then an `HTTPServiceError` will be raised. For example, you might want to assert that the body must be empty, so you could return `len(response.content) == 0`. In the default implementation, a response is acceptable if and only if the response code is either less than 300 (typically 200, i.e. OK) or if it is in the `expected_response_codes` parameter in the constructor.
[ "Override", "this", "method", "to", "create", "a", "different", "definition", "of", "what", "kind", "of", "response", "is", "acceptable", ".", "If", "bool", "(", "the_return_value", ")", "is", "False", "then", "an", "HTTPServiceError", "will", "be", "raised", "." ]
train
https://github.com/yola/demands/blob/816ae4a2684f077f5bb555844ee5f14228b20dba/demands/__init__.py#L128-L144
flatangle/flatlib
flatlib/angle.py
_roundSlist
def _roundSlist(slist): """ Rounds a signed list over the last element and removes it. """ slist[-1] = 60 if slist[-1] >= 30 else 0 for i in range(len(slist)-1, 1, -1): if slist[i] == 60: slist[i] = 0 slist[i-1] += 1 return slist[:-1]
python
def _roundSlist(slist): """ Rounds a signed list over the last element and removes it. """ slist[-1] = 60 if slist[-1] >= 30 else 0 for i in range(len(slist)-1, 1, -1): if slist[i] == 60: slist[i] = 0 slist[i-1] += 1 return slist[:-1]
[ "def", "_roundSlist", "(", "slist", ")", ":", "slist", "[", "-", "1", "]", "=", "60", "if", "slist", "[", "-", "1", "]", ">=", "30", "else", "0", "for", "i", "in", "range", "(", "len", "(", "slist", ")", "-", "1", ",", "1", ",", "-", "1", ")", ":", "if", "slist", "[", "i", "]", "==", "60", ":", "slist", "[", "i", "]", "=", "0", "slist", "[", "i", "-", "1", "]", "+=", "1", "return", "slist", "[", ":", "-", "1", "]" ]
Rounds a signed list over the last element and removes it.
[ "Rounds", "a", "signed", "list", "over", "the", "last", "element", "and", "removes", "it", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L58-L65
flatangle/flatlib
flatlib/angle.py
strSlist
def strSlist(string): """ Converts angle string to signed list. """ sign = '-' if string[0] == '-' else '+' values = [abs(int(x)) for x in string.split(':')] return _fixSlist(list(sign) + values)
python
def strSlist(string): """ Converts angle string to signed list. """ sign = '-' if string[0] == '-' else '+' values = [abs(int(x)) for x in string.split(':')] return _fixSlist(list(sign) + values)
[ "def", "strSlist", "(", "string", ")", ":", "sign", "=", "'-'", "if", "string", "[", "0", "]", "==", "'-'", "else", "'+'", "values", "=", "[", "abs", "(", "int", "(", "x", ")", ")", "for", "x", "in", "string", ".", "split", "(", "':'", ")", "]", "return", "_fixSlist", "(", "list", "(", "sign", ")", "+", "values", ")" ]
Converts angle string to signed list.
[ "Converts", "angle", "string", "to", "signed", "list", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L70-L74
flatangle/flatlib
flatlib/angle.py
slistStr
def slistStr(slist): """ Converts signed list to angle string. """ slist = _fixSlist(slist) string = ':'.join(['%02d' % x for x in slist[1:]]) return slist[0] + string
python
def slistStr(slist): """ Converts signed list to angle string. """ slist = _fixSlist(slist) string = ':'.join(['%02d' % x for x in slist[1:]]) return slist[0] + string
[ "def", "slistStr", "(", "slist", ")", ":", "slist", "=", "_fixSlist", "(", "slist", ")", "string", "=", "':'", ".", "join", "(", "[", "'%02d'", "%", "x", "for", "x", "in", "slist", "[", "1", ":", "]", "]", ")", "return", "slist", "[", "0", "]", "+", "string" ]
Converts signed list to angle string.
[ "Converts", "signed", "list", "to", "angle", "string", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L76-L80
flatangle/flatlib
flatlib/angle.py
slistFloat
def slistFloat(slist): """ Converts signed list to float. """ values = [v / 60**(i) for (i,v) in enumerate(slist[1:])] value = sum(values) return -value if slist[0] == '-' else value
python
def slistFloat(slist): """ Converts signed list to float. """ values = [v / 60**(i) for (i,v) in enumerate(slist[1:])] value = sum(values) return -value if slist[0] == '-' else value
[ "def", "slistFloat", "(", "slist", ")", ":", "values", "=", "[", "v", "/", "60", "**", "(", "i", ")", "for", "(", "i", ",", "v", ")", "in", "enumerate", "(", "slist", "[", "1", ":", "]", ")", "]", "value", "=", "sum", "(", "values", ")", "return", "-", "value", "if", "slist", "[", "0", "]", "==", "'-'", "else", "value" ]
Converts signed list to float.
[ "Converts", "signed", "list", "to", "float", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L82-L86
flatangle/flatlib
flatlib/angle.py
floatSlist
def floatSlist(value): """ Converts float to signed list. """ slist = ['+', 0, 0, 0, 0] if value < 0: slist[0] = '-' value = abs(value) for i in range(1,5): slist[i] = math.floor(value) value = (value - slist[i]) * 60 return _roundSlist(slist)
python
def floatSlist(value): """ Converts float to signed list. """ slist = ['+', 0, 0, 0, 0] if value < 0: slist[0] = '-' value = abs(value) for i in range(1,5): slist[i] = math.floor(value) value = (value - slist[i]) * 60 return _roundSlist(slist)
[ "def", "floatSlist", "(", "value", ")", ":", "slist", "=", "[", "'+'", ",", "0", ",", "0", ",", "0", ",", "0", "]", "if", "value", "<", "0", ":", "slist", "[", "0", "]", "=", "'-'", "value", "=", "abs", "(", "value", ")", "for", "i", "in", "range", "(", "1", ",", "5", ")", ":", "slist", "[", "i", "]", "=", "math", ".", "floor", "(", "value", ")", "value", "=", "(", "value", "-", "slist", "[", "i", "]", ")", "*", "60", "return", "_roundSlist", "(", "slist", ")" ]
Converts float to signed list.
[ "Converts", "float", "to", "signed", "list", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L88-L97
flatangle/flatlib
flatlib/angle.py
toFloat
def toFloat(value): """ Converts string or signed list to float. """ if isinstance(value, str): return strFloat(value) elif isinstance(value, list): return slistFloat(value) else: return value
python
def toFloat(value): """ Converts string or signed list to float. """ if isinstance(value, str): return strFloat(value) elif isinstance(value, list): return slistFloat(value) else: return value
[ "def", "toFloat", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "strFloat", "(", "value", ")", "elif", "isinstance", "(", "value", ",", "list", ")", ":", "return", "slistFloat", "(", "value", ")", "else", ":", "return", "value" ]
Converts string or signed list to float.
[ "Converts", "string", "or", "signed", "list", "to", "float", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L112-L119
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.inDignities
def inDignities(self, idA, idB): """ Returns the dignities of A which belong to B. """ objA = self.chart.get(idA) info = essential.getInfo(objA.sign, objA.signlon) # Should we ignore exile and fall? return [dign for (dign, ID) in info.items() if ID == idB]
python
def inDignities(self, idA, idB): """ Returns the dignities of A which belong to B. """ objA = self.chart.get(idA) info = essential.getInfo(objA.sign, objA.signlon) # Should we ignore exile and fall? return [dign for (dign, ID) in info.items() if ID == idB]
[ "def", "inDignities", "(", "self", ",", "idA", ",", "idB", ")", ":", "objA", "=", "self", ".", "chart", ".", "get", "(", "idA", ")", "info", "=", "essential", ".", "getInfo", "(", "objA", ".", "sign", ",", "objA", ".", "signlon", ")", "# Should we ignore exile and fall?", "return", "[", "dign", "for", "(", "dign", ",", "ID", ")", "in", "info", ".", "items", "(", ")", "if", "ID", "==", "idB", "]" ]
Returns the dignities of A which belong to B.
[ "Returns", "the", "dignities", "of", "A", "which", "belong", "to", "B", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L29-L34
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.receives
def receives(self, idA, idB): """ Returns the dignities where A receives B. A receives B when (1) B aspects A and (2) B is in dignities of A. """ objA = self.chart.get(idA) objB = self.chart.get(idB) asp = aspects.isAspecting(objB, objA, const.MAJOR_ASPECTS) return self.inDignities(idB, idA) if asp else []
python
def receives(self, idA, idB): """ Returns the dignities where A receives B. A receives B when (1) B aspects A and (2) B is in dignities of A. """ objA = self.chart.get(idA) objB = self.chart.get(idB) asp = aspects.isAspecting(objB, objA, const.MAJOR_ASPECTS) return self.inDignities(idB, idA) if asp else []
[ "def", "receives", "(", "self", ",", "idA", ",", "idB", ")", ":", "objA", "=", "self", ".", "chart", ".", "get", "(", "idA", ")", "objB", "=", "self", ".", "chart", ".", "get", "(", "idB", ")", "asp", "=", "aspects", ".", "isAspecting", "(", "objB", ",", "objA", ",", "const", ".", "MAJOR_ASPECTS", ")", "return", "self", ".", "inDignities", "(", "idB", ",", "idA", ")", "if", "asp", "else", "[", "]" ]
Returns the dignities where A receives B. A receives B when (1) B aspects A and (2) B is in dignities of A.
[ "Returns", "the", "dignities", "where", "A", "receives", "B", ".", "A", "receives", "B", "when", "(", "1", ")", "B", "aspects", "A", "and", "(", "2", ")", "B", "is", "in", "dignities", "of", "A", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L36-L45
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.mutualReceptions
def mutualReceptions(self, idA, idB): """ Returns all pairs of dignities in mutual reception. """ AB = self.receives(idA, idB) BA = self.receives(idB, idA) # Returns a product of both lists return [(a,b) for a in AB for b in BA]
python
def mutualReceptions(self, idA, idB): """ Returns all pairs of dignities in mutual reception. """ AB = self.receives(idA, idB) BA = self.receives(idB, idA) # Returns a product of both lists return [(a,b) for a in AB for b in BA]
[ "def", "mutualReceptions", "(", "self", ",", "idA", ",", "idB", ")", ":", "AB", "=", "self", ".", "receives", "(", "idA", ",", "idB", ")", "BA", "=", "self", ".", "receives", "(", "idB", ",", "idA", ")", "# Returns a product of both lists", "return", "[", "(", "a", ",", "b", ")", "for", "a", "in", "AB", "for", "b", "in", "BA", "]" ]
Returns all pairs of dignities in mutual reception.
[ "Returns", "all", "pairs", "of", "dignities", "in", "mutual", "reception", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L51-L56
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.reMutualReceptions
def reMutualReceptions(self, idA, idB): """ Returns ruler and exaltation mutual receptions. """ mr = self.mutualReceptions(idA, idB) filter_ = ['ruler', 'exalt'] # Each pair of dignities must be 'ruler' or 'exalt' return [(a,b) for (a,b) in mr if (a in filter_ and b in filter_)]
python
def reMutualReceptions(self, idA, idB): """ Returns ruler and exaltation mutual receptions. """ mr = self.mutualReceptions(idA, idB) filter_ = ['ruler', 'exalt'] # Each pair of dignities must be 'ruler' or 'exalt' return [(a,b) for (a,b) in mr if (a in filter_ and b in filter_)]
[ "def", "reMutualReceptions", "(", "self", ",", "idA", ",", "idB", ")", ":", "mr", "=", "self", ".", "mutualReceptions", "(", "idA", ",", "idB", ")", "filter_", "=", "[", "'ruler'", ",", "'exalt'", "]", "# Each pair of dignities must be 'ruler' or 'exalt'", "return", "[", "(", "a", ",", "b", ")", "for", "(", "a", ",", "b", ")", "in", "mr", "if", "(", "a", "in", "filter_", "and", "b", "in", "filter_", ")", "]" ]
Returns ruler and exaltation mutual receptions.
[ "Returns", "ruler", "and", "exaltation", "mutual", "receptions", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L58-L63
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.validAspects
def validAspects(self, ID, aspList): """ Returns a list with the aspects an object makes with the other six planets, considering a list of possible aspects. """ obj = self.chart.getObject(ID) res = [] for otherID in const.LIST_SEVEN_PLANETS: if ID == otherID: continue otherObj = self.chart.getObject(otherID) aspType = aspects.aspectType(obj, otherObj, aspList) if aspType != const.NO_ASPECT: res.append({ 'id': otherID, 'asp': aspType, }) return res
python
def validAspects(self, ID, aspList): """ Returns a list with the aspects an object makes with the other six planets, considering a list of possible aspects. """ obj = self.chart.getObject(ID) res = [] for otherID in const.LIST_SEVEN_PLANETS: if ID == otherID: continue otherObj = self.chart.getObject(otherID) aspType = aspects.aspectType(obj, otherObj, aspList) if aspType != const.NO_ASPECT: res.append({ 'id': otherID, 'asp': aspType, }) return res
[ "def", "validAspects", "(", "self", ",", "ID", ",", "aspList", ")", ":", "obj", "=", "self", ".", "chart", ".", "getObject", "(", "ID", ")", "res", "=", "[", "]", "for", "otherID", "in", "const", ".", "LIST_SEVEN_PLANETS", ":", "if", "ID", "==", "otherID", ":", "continue", "otherObj", "=", "self", ".", "chart", ".", "getObject", "(", "otherID", ")", "aspType", "=", "aspects", ".", "aspectType", "(", "obj", ",", "otherObj", ",", "aspList", ")", "if", "aspType", "!=", "const", ".", "NO_ASPECT", ":", "res", ".", "append", "(", "{", "'id'", ":", "otherID", ",", "'asp'", ":", "aspType", ",", "}", ")", "return", "res" ]
Returns a list with the aspects an object makes with the other six planets, considering a list of possible aspects.
[ "Returns", "a", "list", "with", "the", "aspects", "an", "object", "makes", "with", "the", "other", "six", "planets", "considering", "a", "list", "of", "possible", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L68-L88
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.aspectsByCat
def aspectsByCat(self, ID, aspList): """ Returns the aspects an object makes with the other six planets, separated by category (applicative, separative, exact). Aspects must be within orb of the object. """ res = { const.APPLICATIVE: [], const.SEPARATIVE: [], const.EXACT: [], const.NO_MOVEMENT: [] } objA = self.chart.getObject(ID) valid = self.validAspects(ID, aspList) for elem in valid: objB = self.chart.getObject(elem['id']) asp = aspects.getAspect(objA, objB, aspList) role = asp.getRole(objA.id) if role['inOrb']: movement = role['movement'] res[movement].append({ 'id': objB.id, 'asp': asp.type, 'orb': asp.orb }) return res
python
def aspectsByCat(self, ID, aspList): """ Returns the aspects an object makes with the other six planets, separated by category (applicative, separative, exact). Aspects must be within orb of the object. """ res = { const.APPLICATIVE: [], const.SEPARATIVE: [], const.EXACT: [], const.NO_MOVEMENT: [] } objA = self.chart.getObject(ID) valid = self.validAspects(ID, aspList) for elem in valid: objB = self.chart.getObject(elem['id']) asp = aspects.getAspect(objA, objB, aspList) role = asp.getRole(objA.id) if role['inOrb']: movement = role['movement'] res[movement].append({ 'id': objB.id, 'asp': asp.type, 'orb': asp.orb }) return res
[ "def", "aspectsByCat", "(", "self", ",", "ID", ",", "aspList", ")", ":", "res", "=", "{", "const", ".", "APPLICATIVE", ":", "[", "]", ",", "const", ".", "SEPARATIVE", ":", "[", "]", ",", "const", ".", "EXACT", ":", "[", "]", ",", "const", ".", "NO_MOVEMENT", ":", "[", "]", "}", "objA", "=", "self", ".", "chart", ".", "getObject", "(", "ID", ")", "valid", "=", "self", ".", "validAspects", "(", "ID", ",", "aspList", ")", "for", "elem", "in", "valid", ":", "objB", "=", "self", ".", "chart", ".", "getObject", "(", "elem", "[", "'id'", "]", ")", "asp", "=", "aspects", ".", "getAspect", "(", "objA", ",", "objB", ",", "aspList", ")", "role", "=", "asp", ".", "getRole", "(", "objA", ".", "id", ")", "if", "role", "[", "'inOrb'", "]", ":", "movement", "=", "role", "[", "'movement'", "]", "res", "[", "movement", "]", ".", "append", "(", "{", "'id'", ":", "objB", ".", "id", ",", "'asp'", ":", "asp", ".", "type", ",", "'orb'", ":", "asp", ".", "orb", "}", ")", "return", "res" ]
Returns the aspects an object makes with the other six planets, separated by category (applicative, separative, exact). Aspects must be within orb of the object.
[ "Returns", "the", "aspects", "an", "object", "makes", "with", "the", "other", "six", "planets", "separated", "by", "category", "(", "applicative", "separative", "exact", ")", ".", "Aspects", "must", "be", "within", "orb", "of", "the", "object", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L90-L118
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.immediateAspects
def immediateAspects(self, ID, aspList): """ Returns the last separation and next application considering a list of possible aspects. """ asps = self.aspectsByCat(ID, aspList) applications = asps[const.APPLICATIVE] separations = asps[const.SEPARATIVE] exact = asps[const.EXACT] # Get applications and separations sorted by orb applications = applications + [val for val in exact if val['orb'] >= 0] applications = sorted(applications, key=lambda var: var['orb']) separations = sorted(separations, key=lambda var: var['orb']) return ( separations[0] if separations else None, applications[0] if applications else None )
python
def immediateAspects(self, ID, aspList): """ Returns the last separation and next application considering a list of possible aspects. """ asps = self.aspectsByCat(ID, aspList) applications = asps[const.APPLICATIVE] separations = asps[const.SEPARATIVE] exact = asps[const.EXACT] # Get applications and separations sorted by orb applications = applications + [val for val in exact if val['orb'] >= 0] applications = sorted(applications, key=lambda var: var['orb']) separations = sorted(separations, key=lambda var: var['orb']) return ( separations[0] if separations else None, applications[0] if applications else None )
[ "def", "immediateAspects", "(", "self", ",", "ID", ",", "aspList", ")", ":", "asps", "=", "self", ".", "aspectsByCat", "(", "ID", ",", "aspList", ")", "applications", "=", "asps", "[", "const", ".", "APPLICATIVE", "]", "separations", "=", "asps", "[", "const", ".", "SEPARATIVE", "]", "exact", "=", "asps", "[", "const", ".", "EXACT", "]", "# Get applications and separations sorted by orb", "applications", "=", "applications", "+", "[", "val", "for", "val", "in", "exact", "if", "val", "[", "'orb'", "]", ">=", "0", "]", "applications", "=", "sorted", "(", "applications", ",", "key", "=", "lambda", "var", ":", "var", "[", "'orb'", "]", ")", "separations", "=", "sorted", "(", "separations", ",", "key", "=", "lambda", "var", ":", "var", "[", "'orb'", "]", ")", "return", "(", "separations", "[", "0", "]", "if", "separations", "else", "None", ",", "applications", "[", "0", "]", "if", "applications", "else", "None", ")" ]
Returns the last separation and next application considering a list of possible aspects.
[ "Returns", "the", "last", "separation", "and", "next", "application", "considering", "a", "list", "of", "possible", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L120-L141
flatangle/flatlib
flatlib/tools/chartdynamics.py
ChartDynamics.isVOC
def isVOC(self, ID): """ Returns if a planet is Void of Course. A planet is not VOC if has any exact or applicative aspects ignoring the sign status (associate or dissociate). """ asps = self.aspectsByCat(ID, const.MAJOR_ASPECTS) applications = asps[const.APPLICATIVE] exacts = asps[const.EXACT] return len(applications) == 0 and len(exacts) == 0
python
def isVOC(self, ID): """ Returns if a planet is Void of Course. A planet is not VOC if has any exact or applicative aspects ignoring the sign status (associate or dissociate). """ asps = self.aspectsByCat(ID, const.MAJOR_ASPECTS) applications = asps[const.APPLICATIVE] exacts = asps[const.EXACT] return len(applications) == 0 and len(exacts) == 0
[ "def", "isVOC", "(", "self", ",", "ID", ")", ":", "asps", "=", "self", ".", "aspectsByCat", "(", "ID", ",", "const", ".", "MAJOR_ASPECTS", ")", "applications", "=", "asps", "[", "const", ".", "APPLICATIVE", "]", "exacts", "=", "asps", "[", "const", ".", "EXACT", "]", "return", "len", "(", "applications", ")", "==", "0", "and", "len", "(", "exacts", ")", "==", "0" ]
Returns if a planet is Void of Course. A planet is not VOC if has any exact or applicative aspects ignoring the sign status (associate or dissociate).
[ "Returns", "if", "a", "planet", "is", "Void", "of", "Course", ".", "A", "planet", "is", "not", "VOC", "if", "has", "any", "exact", "or", "applicative", "aspects", "ignoring", "the", "sign", "status", "(", "associate", "or", "dissociate", ")", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/chartdynamics.py#L143-L152
flatangle/flatlib
flatlib/protocols/temperament.py
singleFactor
def singleFactor(factors, chart, factor, obj, aspect=None): """" Single factor for the table. """ objID = obj if type(obj) == str else obj.id res = { 'factor': factor, 'objID': objID, 'aspect': aspect } # For signs (obj as string) return sign element if type(obj) == str: res['element'] = props.sign.element[obj] # For Sun return sign and sunseason element elif objID == const.SUN: sunseason = props.sign.sunseason[obj.sign] res['sign'] = obj.sign res['sunseason'] = sunseason res['element'] = props.base.sunseasonElement[sunseason] # For Moon return phase and phase element elif objID == const.MOON: phase = chart.getMoonPhase() res['phase'] = phase res['element'] = props.base.moonphaseElement[phase] # For regular planets return element or sign/sign element # if there's an aspect involved elif objID in const.LIST_SEVEN_PLANETS: if aspect: res['sign'] = obj.sign res['element'] = props.sign.element[obj.sign] else: res['element'] = obj.element() try: # If there's element, insert into list res['element'] factors.append(res) except KeyError: pass return res
python
def singleFactor(factors, chart, factor, obj, aspect=None): """" Single factor for the table. """ objID = obj if type(obj) == str else obj.id res = { 'factor': factor, 'objID': objID, 'aspect': aspect } # For signs (obj as string) return sign element if type(obj) == str: res['element'] = props.sign.element[obj] # For Sun return sign and sunseason element elif objID == const.SUN: sunseason = props.sign.sunseason[obj.sign] res['sign'] = obj.sign res['sunseason'] = sunseason res['element'] = props.base.sunseasonElement[sunseason] # For Moon return phase and phase element elif objID == const.MOON: phase = chart.getMoonPhase() res['phase'] = phase res['element'] = props.base.moonphaseElement[phase] # For regular planets return element or sign/sign element # if there's an aspect involved elif objID in const.LIST_SEVEN_PLANETS: if aspect: res['sign'] = obj.sign res['element'] = props.sign.element[obj.sign] else: res['element'] = obj.element() try: # If there's element, insert into list res['element'] factors.append(res) except KeyError: pass return res
[ "def", "singleFactor", "(", "factors", ",", "chart", ",", "factor", ",", "obj", ",", "aspect", "=", "None", ")", ":", "objID", "=", "obj", "if", "type", "(", "obj", ")", "==", "str", "else", "obj", ".", "id", "res", "=", "{", "'factor'", ":", "factor", ",", "'objID'", ":", "objID", ",", "'aspect'", ":", "aspect", "}", "# For signs (obj as string) return sign element", "if", "type", "(", "obj", ")", "==", "str", ":", "res", "[", "'element'", "]", "=", "props", ".", "sign", ".", "element", "[", "obj", "]", "# For Sun return sign and sunseason element", "elif", "objID", "==", "const", ".", "SUN", ":", "sunseason", "=", "props", ".", "sign", ".", "sunseason", "[", "obj", ".", "sign", "]", "res", "[", "'sign'", "]", "=", "obj", ".", "sign", "res", "[", "'sunseason'", "]", "=", "sunseason", "res", "[", "'element'", "]", "=", "props", ".", "base", ".", "sunseasonElement", "[", "sunseason", "]", "# For Moon return phase and phase element", "elif", "objID", "==", "const", ".", "MOON", ":", "phase", "=", "chart", ".", "getMoonPhase", "(", ")", "res", "[", "'phase'", "]", "=", "phase", "res", "[", "'element'", "]", "=", "props", ".", "base", ".", "moonphaseElement", "[", "phase", "]", "# For regular planets return element or sign/sign element", "# if there's an aspect involved", "elif", "objID", "in", "const", ".", "LIST_SEVEN_PLANETS", ":", "if", "aspect", ":", "res", "[", "'sign'", "]", "=", "obj", ".", "sign", "res", "[", "'element'", "]", "=", "props", ".", "sign", ".", "element", "[", "obj", ".", "sign", "]", "else", ":", "res", "[", "'element'", "]", "=", "obj", ".", "element", "(", ")", "try", ":", "# If there's element, insert into list", "res", "[", "'element'", "]", "factors", ".", "append", "(", "res", ")", "except", "KeyError", ":", "pass", "return", "res" ]
Single factor for the table.
[ "Single", "factor", "for", "the", "table", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L44-L87
flatangle/flatlib
flatlib/protocols/temperament.py
modifierFactor
def modifierFactor(chart, factor, factorObj, otherObj, aspList): """ Computes a factor for a modifier. """ asp = aspects.aspectType(factorObj, otherObj, aspList) if asp != const.NO_ASPECT: return { 'factor': factor, 'aspect': asp, 'objID': otherObj.id, 'element': otherObj.element() } return None
python
def modifierFactor(chart, factor, factorObj, otherObj, aspList): """ Computes a factor for a modifier. """ asp = aspects.aspectType(factorObj, otherObj, aspList) if asp != const.NO_ASPECT: return { 'factor': factor, 'aspect': asp, 'objID': otherObj.id, 'element': otherObj.element() } return None
[ "def", "modifierFactor", "(", "chart", ",", "factor", ",", "factorObj", ",", "otherObj", ",", "aspList", ")", ":", "asp", "=", "aspects", ".", "aspectType", "(", "factorObj", ",", "otherObj", ",", "aspList", ")", "if", "asp", "!=", "const", ".", "NO_ASPECT", ":", "return", "{", "'factor'", ":", "factor", ",", "'aspect'", ":", "asp", ",", "'objID'", ":", "otherObj", ".", "id", ",", "'element'", ":", "otherObj", ".", "element", "(", ")", "}", "return", "None" ]
Computes a factor for a modifier.
[ "Computes", "a", "factor", "for", "a", "modifier", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L90-L101
flatangle/flatlib
flatlib/protocols/temperament.py
getFactors
def getFactors(chart): """ Returns the factors for the temperament. """ factors = [] # Asc sign asc = chart.getAngle(const.ASC) singleFactor(factors, chart, ASC_SIGN, asc.sign) # Asc ruler ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) singleFactor(factors, chart, ASC_RULER, ascRuler) singleFactor(factors, chart, ASC_RULER_SIGN, ascRuler.sign) # Planets in House 1 house1 = chart.getHouse(const.HOUSE1) planetsHouse1 = chart.objects.getObjectsInHouse(house1) for obj in planetsHouse1: singleFactor(factors, chart, HOUSE1_PLANETS_IN, obj) # Planets conjunct Asc planetsConjAsc = chart.objects.getObjectsAspecting(asc, [0]) for obj in planetsConjAsc: # Ignore planets already in house 1 if obj not in planetsHouse1: singleFactor(factors, chart, ASC_PLANETS_CONJ, obj) # Planets aspecting Asc cusp aspList = [60, 90, 120, 180] planetsAspAsc = chart.objects.getObjectsAspecting(asc, aspList) for obj in planetsAspAsc: aspect = aspects.aspectType(obj, asc, aspList) singleFactor(factors, chart, ASC_PLANETS_ASP, obj, aspect) # Moon sign and phase moon = chart.getObject(const.MOON) singleFactor(factors, chart, MOON_SIGN, moon.sign) singleFactor(factors, chart, MOON_PHASE, moon) # Moon dispositor moonRulerID = essential.ruler(moon.sign) moonRuler = chart.getObject(moonRulerID) moonFactor = singleFactor(factors, chart, MOON_DISPOSITOR_SIGN, moonRuler.sign) moonFactor['planetID'] = moonRulerID # Append moon dispositor ID # Planets conjunct Moon planetsConjMoon = chart.objects.getObjectsAspecting(moon, [0]) for obj in planetsConjMoon: singleFactor(factors, chart, MOON_PLANETS_CONJ, obj) # Planets aspecting Moon aspList = [60, 90, 120, 180] planetsAspMoon = chart.objects.getObjectsAspecting(moon, aspList) for obj in planetsAspMoon: aspect = aspects.aspectType(obj, moon, aspList) singleFactor(factors, chart, MOON_PLANETS_ASP, obj, aspect) # Sun season sun = chart.getObject(const.SUN) singleFactor(factors, chart, SUN_SEASON, sun) return factors
python
def getFactors(chart): """ Returns the factors for the temperament. """ factors = [] # Asc sign asc = chart.getAngle(const.ASC) singleFactor(factors, chart, ASC_SIGN, asc.sign) # Asc ruler ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) singleFactor(factors, chart, ASC_RULER, ascRuler) singleFactor(factors, chart, ASC_RULER_SIGN, ascRuler.sign) # Planets in House 1 house1 = chart.getHouse(const.HOUSE1) planetsHouse1 = chart.objects.getObjectsInHouse(house1) for obj in planetsHouse1: singleFactor(factors, chart, HOUSE1_PLANETS_IN, obj) # Planets conjunct Asc planetsConjAsc = chart.objects.getObjectsAspecting(asc, [0]) for obj in planetsConjAsc: # Ignore planets already in house 1 if obj not in planetsHouse1: singleFactor(factors, chart, ASC_PLANETS_CONJ, obj) # Planets aspecting Asc cusp aspList = [60, 90, 120, 180] planetsAspAsc = chart.objects.getObjectsAspecting(asc, aspList) for obj in planetsAspAsc: aspect = aspects.aspectType(obj, asc, aspList) singleFactor(factors, chart, ASC_PLANETS_ASP, obj, aspect) # Moon sign and phase moon = chart.getObject(const.MOON) singleFactor(factors, chart, MOON_SIGN, moon.sign) singleFactor(factors, chart, MOON_PHASE, moon) # Moon dispositor moonRulerID = essential.ruler(moon.sign) moonRuler = chart.getObject(moonRulerID) moonFactor = singleFactor(factors, chart, MOON_DISPOSITOR_SIGN, moonRuler.sign) moonFactor['planetID'] = moonRulerID # Append moon dispositor ID # Planets conjunct Moon planetsConjMoon = chart.objects.getObjectsAspecting(moon, [0]) for obj in planetsConjMoon: singleFactor(factors, chart, MOON_PLANETS_CONJ, obj) # Planets aspecting Moon aspList = [60, 90, 120, 180] planetsAspMoon = chart.objects.getObjectsAspecting(moon, aspList) for obj in planetsAspMoon: aspect = aspects.aspectType(obj, moon, aspList) singleFactor(factors, chart, MOON_PLANETS_ASP, obj, aspect) # Sun season sun = chart.getObject(const.SUN) singleFactor(factors, chart, SUN_SEASON, sun) return factors
[ "def", "getFactors", "(", "chart", ")", ":", "factors", "=", "[", "]", "# Asc sign", "asc", "=", "chart", ".", "getAngle", "(", "const", ".", "ASC", ")", "singleFactor", "(", "factors", ",", "chart", ",", "ASC_SIGN", ",", "asc", ".", "sign", ")", "# Asc ruler", "ascRulerID", "=", "essential", ".", "ruler", "(", "asc", ".", "sign", ")", "ascRuler", "=", "chart", ".", "getObject", "(", "ascRulerID", ")", "singleFactor", "(", "factors", ",", "chart", ",", "ASC_RULER", ",", "ascRuler", ")", "singleFactor", "(", "factors", ",", "chart", ",", "ASC_RULER_SIGN", ",", "ascRuler", ".", "sign", ")", "# Planets in House 1", "house1", "=", "chart", ".", "getHouse", "(", "const", ".", "HOUSE1", ")", "planetsHouse1", "=", "chart", ".", "objects", ".", "getObjectsInHouse", "(", "house1", ")", "for", "obj", "in", "planetsHouse1", ":", "singleFactor", "(", "factors", ",", "chart", ",", "HOUSE1_PLANETS_IN", ",", "obj", ")", "# Planets conjunct Asc", "planetsConjAsc", "=", "chart", ".", "objects", ".", "getObjectsAspecting", "(", "asc", ",", "[", "0", "]", ")", "for", "obj", "in", "planetsConjAsc", ":", "# Ignore planets already in house 1", "if", "obj", "not", "in", "planetsHouse1", ":", "singleFactor", "(", "factors", ",", "chart", ",", "ASC_PLANETS_CONJ", ",", "obj", ")", "# Planets aspecting Asc cusp", "aspList", "=", "[", "60", ",", "90", ",", "120", ",", "180", "]", "planetsAspAsc", "=", "chart", ".", "objects", ".", "getObjectsAspecting", "(", "asc", ",", "aspList", ")", "for", "obj", "in", "planetsAspAsc", ":", "aspect", "=", "aspects", ".", "aspectType", "(", "obj", ",", "asc", ",", "aspList", ")", "singleFactor", "(", "factors", ",", "chart", ",", "ASC_PLANETS_ASP", ",", "obj", ",", "aspect", ")", "# Moon sign and phase", "moon", "=", "chart", ".", "getObject", "(", "const", ".", "MOON", ")", "singleFactor", "(", "factors", ",", "chart", ",", "MOON_SIGN", ",", "moon", ".", "sign", ")", "singleFactor", "(", "factors", ",", "chart", ",", "MOON_PHASE", ",", "moon", ")", "# Moon dispositor", "moonRulerID", "=", "essential", ".", "ruler", "(", "moon", ".", "sign", ")", "moonRuler", "=", "chart", ".", "getObject", "(", "moonRulerID", ")", "moonFactor", "=", "singleFactor", "(", "factors", ",", "chart", ",", "MOON_DISPOSITOR_SIGN", ",", "moonRuler", ".", "sign", ")", "moonFactor", "[", "'planetID'", "]", "=", "moonRulerID", "# Append moon dispositor ID", "# Planets conjunct Moon", "planetsConjMoon", "=", "chart", ".", "objects", ".", "getObjectsAspecting", "(", "moon", ",", "[", "0", "]", ")", "for", "obj", "in", "planetsConjMoon", ":", "singleFactor", "(", "factors", ",", "chart", ",", "MOON_PLANETS_CONJ", ",", "obj", ")", "# Planets aspecting Moon", "aspList", "=", "[", "60", ",", "90", ",", "120", ",", "180", "]", "planetsAspMoon", "=", "chart", ".", "objects", ".", "getObjectsAspecting", "(", "moon", ",", "aspList", ")", "for", "obj", "in", "planetsAspMoon", ":", "aspect", "=", "aspects", ".", "aspectType", "(", "obj", ",", "moon", ",", "aspList", ")", "singleFactor", "(", "factors", ",", "chart", ",", "MOON_PLANETS_ASP", ",", "obj", ",", "aspect", ")", "# Sun season", "sun", "=", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "singleFactor", "(", "factors", ",", "chart", ",", "SUN_SEASON", ",", "sun", ")", "return", "factors" ]
Returns the factors for the temperament.
[ "Returns", "the", "factors", "for", "the", "temperament", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L106-L168
flatangle/flatlib
flatlib/protocols/temperament.py
getModifiers
def getModifiers(chart): """ Returns the factors of the temperament modifiers. """ modifiers = [] # Factors which can be affected asc = chart.getAngle(const.ASC) ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) moon = chart.getObject(const.MOON) factors = [ [MOD_ASC, asc], [MOD_ASC_RULER, ascRuler], [MOD_MOON, moon] ] # Factors of affliction mars = chart.getObject(const.MARS) saturn = chart.getObject(const.SATURN) sun = chart.getObject(const.SUN) affect = [ [mars, [0, 90, 180]], [saturn, [0, 90, 180]], [sun, [0]] ] # Do calculations of afflictions for affectingObj, affectingAsps in affect: for factor, affectedObj in factors: modf = modifierFactor(chart, factor, affectedObj, affectingObj, affectingAsps) if modf: modifiers.append(modf) return modifiers
python
def getModifiers(chart): """ Returns the factors of the temperament modifiers. """ modifiers = [] # Factors which can be affected asc = chart.getAngle(const.ASC) ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) moon = chart.getObject(const.MOON) factors = [ [MOD_ASC, asc], [MOD_ASC_RULER, ascRuler], [MOD_MOON, moon] ] # Factors of affliction mars = chart.getObject(const.MARS) saturn = chart.getObject(const.SATURN) sun = chart.getObject(const.SUN) affect = [ [mars, [0, 90, 180]], [saturn, [0, 90, 180]], [sun, [0]] ] # Do calculations of afflictions for affectingObj, affectingAsps in affect: for factor, affectedObj in factors: modf = modifierFactor(chart, factor, affectedObj, affectingObj, affectingAsps) if modf: modifiers.append(modf) return modifiers
[ "def", "getModifiers", "(", "chart", ")", ":", "modifiers", "=", "[", "]", "# Factors which can be affected", "asc", "=", "chart", ".", "getAngle", "(", "const", ".", "ASC", ")", "ascRulerID", "=", "essential", ".", "ruler", "(", "asc", ".", "sign", ")", "ascRuler", "=", "chart", ".", "getObject", "(", "ascRulerID", ")", "moon", "=", "chart", ".", "getObject", "(", "const", ".", "MOON", ")", "factors", "=", "[", "[", "MOD_ASC", ",", "asc", "]", ",", "[", "MOD_ASC_RULER", ",", "ascRuler", "]", ",", "[", "MOD_MOON", ",", "moon", "]", "]", "# Factors of affliction", "mars", "=", "chart", ".", "getObject", "(", "const", ".", "MARS", ")", "saturn", "=", "chart", ".", "getObject", "(", "const", ".", "SATURN", ")", "sun", "=", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "affect", "=", "[", "[", "mars", ",", "[", "0", ",", "90", ",", "180", "]", "]", ",", "[", "saturn", ",", "[", "0", ",", "90", ",", "180", "]", "]", ",", "[", "sun", ",", "[", "0", "]", "]", "]", "# Do calculations of afflictions", "for", "affectingObj", ",", "affectingAsps", "in", "affect", ":", "for", "factor", ",", "affectedObj", "in", "factors", ":", "modf", "=", "modifierFactor", "(", "chart", ",", "factor", ",", "affectedObj", ",", "affectingObj", ",", "affectingAsps", ")", "if", "modf", ":", "modifiers", ".", "append", "(", "modf", ")", "return", "modifiers" ]
Returns the factors of the temperament modifiers.
[ "Returns", "the", "factors", "of", "the", "temperament", "modifiers", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L171-L208
flatangle/flatlib
flatlib/protocols/temperament.py
scores
def scores(factors): """ Computes the score of temperaments and elements. """ temperaments = { const.CHOLERIC: 0, const.MELANCHOLIC: 0, const.SANGUINE: 0, const.PHLEGMATIC: 0 } qualities = { const.HOT: 0, const.COLD: 0, const.DRY: 0, const.HUMID: 0 } for factor in factors: element = factor['element'] # Score temperament temperament = props.base.elementTemperament[element] temperaments[temperament] += 1 # Score qualities tqualities = props.base.temperamentQuality[temperament] qualities[tqualities[0]] += 1 qualities[tqualities[1]] += 1 return { 'temperaments': temperaments, 'qualities': qualities }
python
def scores(factors): """ Computes the score of temperaments and elements. """ temperaments = { const.CHOLERIC: 0, const.MELANCHOLIC: 0, const.SANGUINE: 0, const.PHLEGMATIC: 0 } qualities = { const.HOT: 0, const.COLD: 0, const.DRY: 0, const.HUMID: 0 } for factor in factors: element = factor['element'] # Score temperament temperament = props.base.elementTemperament[element] temperaments[temperament] += 1 # Score qualities tqualities = props.base.temperamentQuality[temperament] qualities[tqualities[0]] += 1 qualities[tqualities[1]] += 1 return { 'temperaments': temperaments, 'qualities': qualities }
[ "def", "scores", "(", "factors", ")", ":", "temperaments", "=", "{", "const", ".", "CHOLERIC", ":", "0", ",", "const", ".", "MELANCHOLIC", ":", "0", ",", "const", ".", "SANGUINE", ":", "0", ",", "const", ".", "PHLEGMATIC", ":", "0", "}", "qualities", "=", "{", "const", ".", "HOT", ":", "0", ",", "const", ".", "COLD", ":", "0", ",", "const", ".", "DRY", ":", "0", ",", "const", ".", "HUMID", ":", "0", "}", "for", "factor", "in", "factors", ":", "element", "=", "factor", "[", "'element'", "]", "# Score temperament", "temperament", "=", "props", ".", "base", ".", "elementTemperament", "[", "element", "]", "temperaments", "[", "temperament", "]", "+=", "1", "# Score qualities", "tqualities", "=", "props", ".", "base", ".", "temperamentQuality", "[", "temperament", "]", "qualities", "[", "tqualities", "[", "0", "]", "]", "+=", "1", "qualities", "[", "tqualities", "[", "1", "]", "]", "+=", "1", "return", "{", "'temperaments'", ":", "temperaments", ",", "'qualities'", ":", "qualities", "}" ]
Computes the score of temperaments and elements.
[ "Computes", "the", "score", "of", "temperaments", "and", "elements", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L211-L245
flatangle/flatlib
flatlib/ephem/ephem.py
getObject
def getObject(ID, date, pos): """ Returns an ephemeris object. """ obj = eph.getObject(ID, date.jd, pos.lat, pos.lon) return Object.fromDict(obj)
python
def getObject(ID, date, pos): """ Returns an ephemeris object. """ obj = eph.getObject(ID, date.jd, pos.lat, pos.lon) return Object.fromDict(obj)
[ "def", "getObject", "(", "ID", ",", "date", ",", "pos", ")", ":", "obj", "=", "eph", ".", "getObject", "(", "ID", ",", "date", ".", "jd", ",", "pos", ".", "lat", ",", "pos", ".", "lon", ")", "return", "Object", ".", "fromDict", "(", "obj", ")" ]
Returns an ephemeris object.
[ "Returns", "an", "ephemeris", "object", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L28-L31
flatangle/flatlib
flatlib/ephem/ephem.py
getObjectList
def getObjectList(IDs, date, pos): """ Returns a list of objects. """ objList = [getObject(ID, date, pos) for ID in IDs] return ObjectList(objList)
python
def getObjectList(IDs, date, pos): """ Returns a list of objects. """ objList = [getObject(ID, date, pos) for ID in IDs] return ObjectList(objList)
[ "def", "getObjectList", "(", "IDs", ",", "date", ",", "pos", ")", ":", "objList", "=", "[", "getObject", "(", "ID", ",", "date", ",", "pos", ")", "for", "ID", "in", "IDs", "]", "return", "ObjectList", "(", "objList", ")" ]
Returns a list of objects.
[ "Returns", "a", "list", "of", "objects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L33-L36
flatangle/flatlib
flatlib/ephem/ephem.py
getHouses
def getHouses(date, pos, hsys): """ Returns the lists of houses and angles. Since houses and angles are computed at the same time, this function should be fast. """ houses, angles = eph.getHouses(date.jd, pos.lat, pos.lon, hsys) hList = [House.fromDict(house) for house in houses] aList = [GenericObject.fromDict(angle) for angle in angles] return (HouseList(hList), GenericList(aList))
python
def getHouses(date, pos, hsys): """ Returns the lists of houses and angles. Since houses and angles are computed at the same time, this function should be fast. """ houses, angles = eph.getHouses(date.jd, pos.lat, pos.lon, hsys) hList = [House.fromDict(house) for house in houses] aList = [GenericObject.fromDict(angle) for angle in angles] return (HouseList(hList), GenericList(aList))
[ "def", "getHouses", "(", "date", ",", "pos", ",", "hsys", ")", ":", "houses", ",", "angles", "=", "eph", ".", "getHouses", "(", "date", ".", "jd", ",", "pos", ".", "lat", ",", "pos", ".", "lon", ",", "hsys", ")", "hList", "=", "[", "House", ".", "fromDict", "(", "house", ")", "for", "house", "in", "houses", "]", "aList", "=", "[", "GenericObject", ".", "fromDict", "(", "angle", ")", "for", "angle", "in", "angles", "]", "return", "(", "HouseList", "(", "hList", ")", ",", "GenericList", "(", "aList", ")", ")" ]
Returns the lists of houses and angles. Since houses and angles are computed at the same time, this function should be fast.
[ "Returns", "the", "lists", "of", "houses", "and", "angles", ".", "Since", "houses", "and", "angles", "are", "computed", "at", "the", "same", "time", "this", "function", "should", "be", "fast", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L41-L51
flatangle/flatlib
flatlib/ephem/ephem.py
getFixedStar
def getFixedStar(ID, date): """ Returns a fixed star from the ephemeris. """ star = eph.getFixedStar(ID, date.jd) return FixedStar.fromDict(star)
python
def getFixedStar(ID, date): """ Returns a fixed star from the ephemeris. """ star = eph.getFixedStar(ID, date.jd) return FixedStar.fromDict(star)
[ "def", "getFixedStar", "(", "ID", ",", "date", ")", ":", "star", "=", "eph", ".", "getFixedStar", "(", "ID", ",", "date", ".", "jd", ")", "return", "FixedStar", ".", "fromDict", "(", "star", ")" ]
Returns a fixed star from the ephemeris.
[ "Returns", "a", "fixed", "star", "from", "the", "ephemeris", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L64-L67
flatangle/flatlib
flatlib/ephem/ephem.py
getFixedStarList
def getFixedStarList(IDs, date): """ Returns a list of fixed stars. """ starList = [getFixedStar(ID, date) for ID in IDs] return FixedStarList(starList)
python
def getFixedStarList(IDs, date): """ Returns a list of fixed stars. """ starList = [getFixedStar(ID, date) for ID in IDs] return FixedStarList(starList)
[ "def", "getFixedStarList", "(", "IDs", ",", "date", ")", ":", "starList", "=", "[", "getFixedStar", "(", "ID", ",", "date", ")", "for", "ID", "in", "IDs", "]", "return", "FixedStarList", "(", "starList", ")" ]
Returns a list of fixed stars.
[ "Returns", "a", "list", "of", "fixed", "stars", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L69-L72
flatangle/flatlib
flatlib/ephem/ephem.py
nextSolarReturn
def nextSolarReturn(date, lon): """ Returns the next date when sun is at longitude 'lon'. """ jd = eph.nextSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
python
def nextSolarReturn(date, lon): """ Returns the next date when sun is at longitude 'lon'. """ jd = eph.nextSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
[ "def", "nextSolarReturn", "(", "date", ",", "lon", ")", ":", "jd", "=", "eph", ".", "nextSolarReturn", "(", "date", ".", "jd", ",", "lon", ")", "return", "Datetime", ".", "fromJD", "(", "jd", ",", "date", ".", "utcoffset", ")" ]
Returns the next date when sun is at longitude 'lon'.
[ "Returns", "the", "next", "date", "when", "sun", "is", "at", "longitude", "lon", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L77-L80
flatangle/flatlib
flatlib/ephem/ephem.py
prevSolarReturn
def prevSolarReturn(date, lon): """ Returns the previous date when sun is at longitude 'lon'. """ jd = eph.prevSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
python
def prevSolarReturn(date, lon): """ Returns the previous date when sun is at longitude 'lon'. """ jd = eph.prevSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
[ "def", "prevSolarReturn", "(", "date", ",", "lon", ")", ":", "jd", "=", "eph", ".", "prevSolarReturn", "(", "date", ".", "jd", ",", "lon", ")", "return", "Datetime", ".", "fromJD", "(", "jd", ",", "date", ".", "utcoffset", ")" ]
Returns the previous date when sun is at longitude 'lon'.
[ "Returns", "the", "previous", "date", "when", "sun", "is", "at", "longitude", "lon", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L82-L85
flatangle/flatlib
flatlib/ephem/ephem.py
nextSunrise
def nextSunrise(date, pos): """ Returns the date of the next sunrise. """ jd = eph.nextSunrise(date.jd, pos.lat, pos.lon) return Datetime.fromJD(jd, date.utcoffset)
python
def nextSunrise(date, pos): """ Returns the date of the next sunrise. """ jd = eph.nextSunrise(date.jd, pos.lat, pos.lon) return Datetime.fromJD(jd, date.utcoffset)
[ "def", "nextSunrise", "(", "date", ",", "pos", ")", ":", "jd", "=", "eph", ".", "nextSunrise", "(", "date", ".", "jd", ",", "pos", ".", "lat", ",", "pos", ".", "lon", ")", "return", "Datetime", ".", "fromJD", "(", "jd", ",", "date", ".", "utcoffset", ")" ]
Returns the date of the next sunrise.
[ "Returns", "the", "date", "of", "the", "next", "sunrise", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L90-L93
flatangle/flatlib
flatlib/ephem/ephem.py
nextStation
def nextStation(ID, date): """ Returns the aproximate date of the next station. """ jd = eph.nextStation(ID, date.jd) return Datetime.fromJD(jd, date.utcoffset)
python
def nextStation(ID, date): """ Returns the aproximate date of the next station. """ jd = eph.nextStation(ID, date.jd) return Datetime.fromJD(jd, date.utcoffset)
[ "def", "nextStation", "(", "ID", ",", "date", ")", ":", "jd", "=", "eph", ".", "nextStation", "(", "ID", ",", "date", ".", "jd", ")", "return", "Datetime", ".", "fromJD", "(", "jd", ",", "date", ".", "utcoffset", ")" ]
Returns the aproximate date of the next station.
[ "Returns", "the", "aproximate", "date", "of", "the", "next", "station", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L113-L116
flatangle/flatlib
flatlib/ephem/ephem.py
prevSolarEclipse
def prevSolarEclipse(date): """ Returns the Datetime of the maximum phase of the previous global solar eclipse. """ eclipse = swe.solarEclipseGlobal(date.jd, backward=True) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
python
def prevSolarEclipse(date): """ Returns the Datetime of the maximum phase of the previous global solar eclipse. """ eclipse = swe.solarEclipseGlobal(date.jd, backward=True) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
[ "def", "prevSolarEclipse", "(", "date", ")", ":", "eclipse", "=", "swe", ".", "solarEclipseGlobal", "(", "date", ".", "jd", ",", "backward", "=", "True", ")", "return", "Datetime", ".", "fromJD", "(", "eclipse", "[", "'maximum'", "]", ",", "date", ".", "utcoffset", ")" ]
Returns the Datetime of the maximum phase of the previous global solar eclipse.
[ "Returns", "the", "Datetime", "of", "the", "maximum", "phase", "of", "the", "previous", "global", "solar", "eclipse", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L121-L128
flatangle/flatlib
flatlib/ephem/ephem.py
nextSolarEclipse
def nextSolarEclipse(date): """ Returns the Datetime of the maximum phase of the next global solar eclipse. """ eclipse = swe.solarEclipseGlobal(date.jd, backward=False) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
python
def nextSolarEclipse(date): """ Returns the Datetime of the maximum phase of the next global solar eclipse. """ eclipse = swe.solarEclipseGlobal(date.jd, backward=False) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
[ "def", "nextSolarEclipse", "(", "date", ")", ":", "eclipse", "=", "swe", ".", "solarEclipseGlobal", "(", "date", ".", "jd", ",", "backward", "=", "False", ")", "return", "Datetime", ".", "fromJD", "(", "eclipse", "[", "'maximum'", "]", ",", "date", ".", "utcoffset", ")" ]
Returns the Datetime of the maximum phase of the next global solar eclipse.
[ "Returns", "the", "Datetime", "of", "the", "maximum", "phase", "of", "the", "next", "global", "solar", "eclipse", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L130-L137
flatangle/flatlib
flatlib/ephem/ephem.py
prevLunarEclipse
def prevLunarEclipse(date): """ Returns the Datetime of the maximum phase of the previous global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=True) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
python
def prevLunarEclipse(date): """ Returns the Datetime of the maximum phase of the previous global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=True) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
[ "def", "prevLunarEclipse", "(", "date", ")", ":", "eclipse", "=", "swe", ".", "lunarEclipseGlobal", "(", "date", ".", "jd", ",", "backward", "=", "True", ")", "return", "Datetime", ".", "fromJD", "(", "eclipse", "[", "'maximum'", "]", ",", "date", ".", "utcoffset", ")" ]
Returns the Datetime of the maximum phase of the previous global lunar eclipse.
[ "Returns", "the", "Datetime", "of", "the", "maximum", "phase", "of", "the", "previous", "global", "lunar", "eclipse", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L139-L146
flatangle/flatlib
flatlib/ephem/ephem.py
nextLunarEclipse
def nextLunarEclipse(date): """ Returns the Datetime of the maximum phase of the next global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=False) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
python
def nextLunarEclipse(date): """ Returns the Datetime of the maximum phase of the next global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=False) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
[ "def", "nextLunarEclipse", "(", "date", ")", ":", "eclipse", "=", "swe", ".", "lunarEclipseGlobal", "(", "date", ".", "jd", ",", "backward", "=", "False", ")", "return", "Datetime", ".", "fromJD", "(", "eclipse", "[", "'maximum'", "]", ",", "date", ".", "utcoffset", ")" ]
Returns the Datetime of the maximum phase of the next global lunar eclipse.
[ "Returns", "the", "Datetime", "of", "the", "maximum", "phase", "of", "the", "next", "global", "lunar", "eclipse", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/ephem.py#L148-L155
flatangle/flatlib
recipes/solaryears.py
plot
def plot(hdiff, title): """ Plots the tropical solar length by year. """ import matplotlib.pyplot as plt years = [elem[0] for elem in hdiff] diffs = [elem[1] for elem in hdiff] plt.plot(years, diffs) plt.ylabel('Distance in minutes') plt.xlabel('Year') plt.title(title) plt.axhline(y=0, c='red') plt.show()
python
def plot(hdiff, title): """ Plots the tropical solar length by year. """ import matplotlib.pyplot as plt years = [elem[0] for elem in hdiff] diffs = [elem[1] for elem in hdiff] plt.plot(years, diffs) plt.ylabel('Distance in minutes') plt.xlabel('Year') plt.title(title) plt.axhline(y=0, c='red') plt.show()
[ "def", "plot", "(", "hdiff", ",", "title", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "years", "=", "[", "elem", "[", "0", "]", "for", "elem", "in", "hdiff", "]", "diffs", "=", "[", "elem", "[", "1", "]", "for", "elem", "in", "hdiff", "]", "plt", ".", "plot", "(", "years", ",", "diffs", ")", "plt", ".", "ylabel", "(", "'Distance in minutes'", ")", "plt", ".", "xlabel", "(", "'Year'", ")", "plt", ".", "title", "(", "title", ")", "plt", ".", "axhline", "(", "y", "=", "0", ",", "c", "=", "'red'", ")", "plt", ".", "show", "(", ")" ]
Plots the tropical solar length by year.
[ "Plots", "the", "tropical", "solar", "length", "by", "year", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/recipes/solaryears.py#L22-L35
flatangle/flatlib
flatlib/utils.py
ascdiff
def ascdiff(decl, lat): """ Returns the Ascensional Difference of a point. """ delta = math.radians(decl) phi = math.radians(lat) ad = math.asin(math.tan(delta) * math.tan(phi)) return math.degrees(ad)
python
def ascdiff(decl, lat): """ Returns the Ascensional Difference of a point. """ delta = math.radians(decl) phi = math.radians(lat) ad = math.asin(math.tan(delta) * math.tan(phi)) return math.degrees(ad)
[ "def", "ascdiff", "(", "decl", ",", "lat", ")", ":", "delta", "=", "math", ".", "radians", "(", "decl", ")", "phi", "=", "math", ".", "radians", "(", "lat", ")", "ad", "=", "math", ".", "asin", "(", "math", ".", "tan", "(", "delta", ")", "*", "math", ".", "tan", "(", "phi", ")", ")", "return", "math", ".", "degrees", "(", "ad", ")" ]
Returns the Ascensional Difference of a point.
[ "Returns", "the", "Ascensional", "Difference", "of", "a", "point", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/utils.py#L14-L19
flatangle/flatlib
flatlib/utils.py
dnarcs
def dnarcs(decl, lat): """ Returns the diurnal and nocturnal arcs of a point. """ dArc = 180 + 2 * ascdiff(decl, lat) nArc = 360 - dArc return (dArc, nArc)
python
def dnarcs(decl, lat): """ Returns the diurnal and nocturnal arcs of a point. """ dArc = 180 + 2 * ascdiff(decl, lat) nArc = 360 - dArc return (dArc, nArc)
[ "def", "dnarcs", "(", "decl", ",", "lat", ")", ":", "dArc", "=", "180", "+", "2", "*", "ascdiff", "(", "decl", ",", "lat", ")", "nArc", "=", "360", "-", "dArc", "return", "(", "dArc", ",", "nArc", ")" ]
Returns the diurnal and nocturnal arcs of a point.
[ "Returns", "the", "diurnal", "and", "nocturnal", "arcs", "of", "a", "point", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/utils.py#L21-L25
flatangle/flatlib
flatlib/utils.py
isAboveHorizon
def isAboveHorizon(ra, decl, mcRA, lat): """ Returns if an object's 'ra' and 'decl' is above the horizon at a specific latitude, given the MC's right ascension. """ # This function checks if the equatorial distance from # the object to the MC is within its diurnal semi-arc. dArc, _ = dnarcs(decl, lat) dist = abs(angle.closestdistance(mcRA, ra)) return dist <= dArc/2.0 + 0.0003
python
def isAboveHorizon(ra, decl, mcRA, lat): """ Returns if an object's 'ra' and 'decl' is above the horizon at a specific latitude, given the MC's right ascension. """ # This function checks if the equatorial distance from # the object to the MC is within its diurnal semi-arc. dArc, _ = dnarcs(decl, lat) dist = abs(angle.closestdistance(mcRA, ra)) return dist <= dArc/2.0 + 0.0003
[ "def", "isAboveHorizon", "(", "ra", ",", "decl", ",", "mcRA", ",", "lat", ")", ":", "# This function checks if the equatorial distance from ", "# the object to the MC is within its diurnal semi-arc.", "dArc", ",", "_", "=", "dnarcs", "(", "decl", ",", "lat", ")", "dist", "=", "abs", "(", "angle", ".", "closestdistance", "(", "mcRA", ",", "ra", ")", ")", "return", "dist", "<=", "dArc", "/", "2.0", "+", "0.0003" ]
Returns if an object's 'ra' and 'decl' is above the horizon at a specific latitude, given the MC's right ascension.
[ "Returns", "if", "an", "object", "s", "ra", "and", "decl", "is", "above", "the", "horizon", "at", "a", "specific", "latitude", "given", "the", "MC", "s", "right", "ascension", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/utils.py#L30-L41
flatangle/flatlib
flatlib/utils.py
eqCoords
def eqCoords(lon, lat): """ Converts from ecliptical to equatorial coordinates. This algorithm is described in book 'Primary Directions', pp. 147-150. """ # Convert to radians _lambda = math.radians(lon) _beta = math.radians(lat) _epson = math.radians(23.44) # The earth's inclination # Declination in radians decl = math.asin(math.sin(_epson) * math.sin(_lambda) * math.cos(_beta) + \ math.cos(_epson) * math.sin(_beta)) # Equatorial Distance in radians ED = math.acos(math.cos(_lambda) * math.cos(_beta) / math.cos(decl)) # RA in radians ra = ED if lon < 180 else math.radians(360) - ED # Correctness of RA if longitude is close to 0º or 180º in a radius of 5º if (abs(angle.closestdistance(lon, 0)) < 5 or abs(angle.closestdistance(lon, 180)) < 5): a = math.sin(ra) * math.cos(decl) b = math.cos(_epson) * math.sin(_lambda) * math.cos(_beta) - \ math.sin(_epson) * math.sin(_beta) if (math.fabs(a-b) > 0.0003): ra = math.radians(360) - ra return (math.degrees(ra), math.degrees(decl))
python
def eqCoords(lon, lat): """ Converts from ecliptical to equatorial coordinates. This algorithm is described in book 'Primary Directions', pp. 147-150. """ # Convert to radians _lambda = math.radians(lon) _beta = math.radians(lat) _epson = math.radians(23.44) # The earth's inclination # Declination in radians decl = math.asin(math.sin(_epson) * math.sin(_lambda) * math.cos(_beta) + \ math.cos(_epson) * math.sin(_beta)) # Equatorial Distance in radians ED = math.acos(math.cos(_lambda) * math.cos(_beta) / math.cos(decl)) # RA in radians ra = ED if lon < 180 else math.radians(360) - ED # Correctness of RA if longitude is close to 0º or 180º in a radius of 5º if (abs(angle.closestdistance(lon, 0)) < 5 or abs(angle.closestdistance(lon, 180)) < 5): a = math.sin(ra) * math.cos(decl) b = math.cos(_epson) * math.sin(_lambda) * math.cos(_beta) - \ math.sin(_epson) * math.sin(_beta) if (math.fabs(a-b) > 0.0003): ra = math.radians(360) - ra return (math.degrees(ra), math.degrees(decl))
[ "def", "eqCoords", "(", "lon", ",", "lat", ")", ":", "# Convert to radians", "_lambda", "=", "math", ".", "radians", "(", "lon", ")", "_beta", "=", "math", ".", "radians", "(", "lat", ")", "_epson", "=", "math", ".", "radians", "(", "23.44", ")", "# The earth's inclination", "# Declination in radians", "decl", "=", "math", ".", "asin", "(", "math", ".", "sin", "(", "_epson", ")", "*", "math", ".", "sin", "(", "_lambda", ")", "*", "math", ".", "cos", "(", "_beta", ")", "+", "math", ".", "cos", "(", "_epson", ")", "*", "math", ".", "sin", "(", "_beta", ")", ")", "# Equatorial Distance in radians", "ED", "=", "math", ".", "acos", "(", "math", ".", "cos", "(", "_lambda", ")", "*", "math", ".", "cos", "(", "_beta", ")", "/", "math", ".", "cos", "(", "decl", ")", ")", "# RA in radians", "ra", "=", "ED", "if", "lon", "<", "180", "else", "math", ".", "radians", "(", "360", ")", "-", "ED", "# Correctness of RA if longitude is close to 0º or 180º in a radius of 5º", "if", "(", "abs", "(", "angle", ".", "closestdistance", "(", "lon", ",", "0", ")", ")", "<", "5", "or", "abs", "(", "angle", ".", "closestdistance", "(", "lon", ",", "180", ")", ")", "<", "5", ")", ":", "a", "=", "math", ".", "sin", "(", "ra", ")", "*", "math", ".", "cos", "(", "decl", ")", "b", "=", "math", ".", "cos", "(", "_epson", ")", "*", "math", ".", "sin", "(", "_lambda", ")", "*", "math", ".", "cos", "(", "_beta", ")", "-", "math", ".", "sin", "(", "_epson", ")", "*", "math", ".", "sin", "(", "_beta", ")", "if", "(", "math", ".", "fabs", "(", "a", "-", "b", ")", ">", "0.0003", ")", ":", "ra", "=", "math", ".", "radians", "(", "360", ")", "-", "ra", "return", "(", "math", ".", "degrees", "(", "ra", ")", ",", "math", ".", "degrees", "(", "decl", ")", ")" ]
Converts from ecliptical to equatorial coordinates. This algorithm is described in book 'Primary Directions', pp. 147-150.
[ "Converts", "from", "ecliptical", "to", "equatorial", "coordinates", ".", "This", "algorithm", "is", "described", "in", "book", "Primary", "Directions", "pp", ".", "147", "-", "150", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/utils.py#L46-L76
flatangle/flatlib
flatlib/dignities/accidental.py
sunRelation
def sunRelation(obj, sun): """ Returns an object's relation with the sun. """ if obj.id == const.SUN: return None dist = abs(angle.closestdistance(sun.lon, obj.lon)) if dist < 0.2833: return CAZIMI elif dist < 8.0: return COMBUST elif dist < 16.0: return UNDER_SUN else: return None
python
def sunRelation(obj, sun): """ Returns an object's relation with the sun. """ if obj.id == const.SUN: return None dist = abs(angle.closestdistance(sun.lon, obj.lon)) if dist < 0.2833: return CAZIMI elif dist < 8.0: return COMBUST elif dist < 16.0: return UNDER_SUN else: return None
[ "def", "sunRelation", "(", "obj", ",", "sun", ")", ":", "if", "obj", ".", "id", "==", "const", ".", "SUN", ":", "return", "None", "dist", "=", "abs", "(", "angle", ".", "closestdistance", "(", "sun", ".", "lon", ",", "obj", ".", "lon", ")", ")", "if", "dist", "<", "0.2833", ":", "return", "CAZIMI", "elif", "dist", "<", "8.0", ":", "return", "COMBUST", "elif", "dist", "<", "16.0", ":", "return", "UNDER_SUN", "else", ":", "return", "None" ]
Returns an object's relation with the sun.
[ "Returns", "an", "object", "s", "relation", "with", "the", "sun", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L42-L51
flatangle/flatlib
flatlib/dignities/accidental.py
light
def light(obj, sun): """ Returns if an object is augmenting or diminishing light. """ dist = angle.distance(sun.lon, obj.lon) faster = sun if sun.lonspeed > obj.lonspeed else obj if faster == sun: return LIGHT_DIMINISHING if dist < 180 else LIGHT_AUGMENTING else: return LIGHT_AUGMENTING if dist < 180 else LIGHT_DIMINISHING
python
def light(obj, sun): """ Returns if an object is augmenting or diminishing light. """ dist = angle.distance(sun.lon, obj.lon) faster = sun if sun.lonspeed > obj.lonspeed else obj if faster == sun: return LIGHT_DIMINISHING if dist < 180 else LIGHT_AUGMENTING else: return LIGHT_AUGMENTING if dist < 180 else LIGHT_DIMINISHING
[ "def", "light", "(", "obj", ",", "sun", ")", ":", "dist", "=", "angle", ".", "distance", "(", "sun", ".", "lon", ",", "obj", ".", "lon", ")", "faster", "=", "sun", "if", "sun", ".", "lonspeed", ">", "obj", ".", "lonspeed", "else", "obj", "if", "faster", "==", "sun", ":", "return", "LIGHT_DIMINISHING", "if", "dist", "<", "180", "else", "LIGHT_AUGMENTING", "else", ":", "return", "LIGHT_AUGMENTING", "if", "dist", "<", "180", "else", "LIGHT_DIMINISHING" ]
Returns if an object is augmenting or diminishing light.
[ "Returns", "if", "an", "object", "is", "augmenting", "or", "diminishing", "light", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L53-L60
flatangle/flatlib
flatlib/dignities/accidental.py
orientality
def orientality(obj, sun): """ Returns if an object is oriental or occidental to the sun. """ dist = angle.distance(sun.lon, obj.lon) return OCCIDENTAL if dist < 180 else ORIENTAL
python
def orientality(obj, sun): """ Returns if an object is oriental or occidental to the sun. """ dist = angle.distance(sun.lon, obj.lon) return OCCIDENTAL if dist < 180 else ORIENTAL
[ "def", "orientality", "(", "obj", ",", "sun", ")", ":", "dist", "=", "angle", ".", "distance", "(", "sun", ".", "lon", ",", "obj", ".", "lon", ")", "return", "OCCIDENTAL", "if", "dist", "<", "180", "else", "ORIENTAL" ]
Returns if an object is oriental or occidental to the sun.
[ "Returns", "if", "an", "object", "is", "oriental", "or", "occidental", "to", "the", "sun", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L62-L68
flatangle/flatlib
flatlib/dignities/accidental.py
haiz
def haiz(obj, chart): """ Returns if an object is in Haiz. """ objGender = obj.gender() objFaction = obj.faction() if obj.id == const.MERCURY: # Gender and faction of mercury depends on orientality sun = chart.getObject(const.SUN) orientalityM = orientality(obj, sun) if orientalityM == ORIENTAL: objGender = const.MASCULINE objFaction = const.DIURNAL else: objGender = const.FEMININE objFaction = const.NOCTURNAL # Object gender match sign gender? signGender = props.sign.gender[obj.sign] genderConformity = (objGender == signGender) # Match faction factionConformity = False diurnalChart = chart.isDiurnal() if obj.id == const.SUN and not diurnalChart: # Sun is in conformity only when above horizon factionConformity = False else: # Get list of houses in the chart's diurnal faction if diurnalChart: diurnalFaction = props.house.aboveHorizon nocturnalFaction = props.house.belowHorizon else: diurnalFaction = props.house.belowHorizon nocturnalFaction = props.house.aboveHorizon # Get the object's house and match factions objHouse = chart.houses.getObjectHouse(obj) if (objFaction == const.DIURNAL and objHouse.id in diurnalFaction or objFaction == const.NOCTURNAL and objHouse.id in nocturnalFaction): factionConformity = True # Match things if (genderConformity and factionConformity): return HAIZ elif (not genderConformity and not factionConformity): return CHAIZ else: return None
python
def haiz(obj, chart): """ Returns if an object is in Haiz. """ objGender = obj.gender() objFaction = obj.faction() if obj.id == const.MERCURY: # Gender and faction of mercury depends on orientality sun = chart.getObject(const.SUN) orientalityM = orientality(obj, sun) if orientalityM == ORIENTAL: objGender = const.MASCULINE objFaction = const.DIURNAL else: objGender = const.FEMININE objFaction = const.NOCTURNAL # Object gender match sign gender? signGender = props.sign.gender[obj.sign] genderConformity = (objGender == signGender) # Match faction factionConformity = False diurnalChart = chart.isDiurnal() if obj.id == const.SUN and not diurnalChart: # Sun is in conformity only when above horizon factionConformity = False else: # Get list of houses in the chart's diurnal faction if diurnalChart: diurnalFaction = props.house.aboveHorizon nocturnalFaction = props.house.belowHorizon else: diurnalFaction = props.house.belowHorizon nocturnalFaction = props.house.aboveHorizon # Get the object's house and match factions objHouse = chart.houses.getObjectHouse(obj) if (objFaction == const.DIURNAL and objHouse.id in diurnalFaction or objFaction == const.NOCTURNAL and objHouse.id in nocturnalFaction): factionConformity = True # Match things if (genderConformity and factionConformity): return HAIZ elif (not genderConformity and not factionConformity): return CHAIZ else: return None
[ "def", "haiz", "(", "obj", ",", "chart", ")", ":", "objGender", "=", "obj", ".", "gender", "(", ")", "objFaction", "=", "obj", ".", "faction", "(", ")", "if", "obj", ".", "id", "==", "const", ".", "MERCURY", ":", "# Gender and faction of mercury depends on orientality", "sun", "=", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "orientalityM", "=", "orientality", "(", "obj", ",", "sun", ")", "if", "orientalityM", "==", "ORIENTAL", ":", "objGender", "=", "const", ".", "MASCULINE", "objFaction", "=", "const", ".", "DIURNAL", "else", ":", "objGender", "=", "const", ".", "FEMININE", "objFaction", "=", "const", ".", "NOCTURNAL", "# Object gender match sign gender?", "signGender", "=", "props", ".", "sign", ".", "gender", "[", "obj", ".", "sign", "]", "genderConformity", "=", "(", "objGender", "==", "signGender", ")", "# Match faction", "factionConformity", "=", "False", "diurnalChart", "=", "chart", ".", "isDiurnal", "(", ")", "if", "obj", ".", "id", "==", "const", ".", "SUN", "and", "not", "diurnalChart", ":", "# Sun is in conformity only when above horizon", "factionConformity", "=", "False", "else", ":", "# Get list of houses in the chart's diurnal faction", "if", "diurnalChart", ":", "diurnalFaction", "=", "props", ".", "house", ".", "aboveHorizon", "nocturnalFaction", "=", "props", ".", "house", ".", "belowHorizon", "else", ":", "diurnalFaction", "=", "props", ".", "house", ".", "belowHorizon", "nocturnalFaction", "=", "props", ".", "house", ".", "aboveHorizon", "# Get the object's house and match factions", "objHouse", "=", "chart", ".", "houses", ".", "getObjectHouse", "(", "obj", ")", "if", "(", "objFaction", "==", "const", ".", "DIURNAL", "and", "objHouse", ".", "id", "in", "diurnalFaction", "or", "objFaction", "==", "const", ".", "NOCTURNAL", "and", "objHouse", ".", "id", "in", "nocturnalFaction", ")", ":", "factionConformity", "=", "True", "# Match things", "if", "(", "genderConformity", "and", "factionConformity", ")", ":", "return", "HAIZ", "elif", "(", "not", "genderConformity", "and", "not", "factionConformity", ")", ":", "return", "CHAIZ", "else", ":", "return", "None" ]
Returns if an object is in Haiz.
[ "Returns", "if", "an", "object", "is", "in", "Haiz", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L74-L122
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.house
def house(self): """ Returns the object's house. """ house = self.chart.houses.getObjectHouse(self.obj) return house
python
def house(self): """ Returns the object's house. """ house = self.chart.houses.getObjectHouse(self.obj) return house
[ "def", "house", "(", "self", ")", ":", "house", "=", "self", ".", "chart", ".", "houses", ".", "getObjectHouse", "(", "self", ".", "obj", ")", "return", "house" ]
Returns the object's house.
[ "Returns", "the", "object", "s", "house", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L161-L164
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.sunRelation
def sunRelation(self): """ Returns the relation of the object with the sun. """ sun = self.chart.getObject(const.SUN) return sunRelation(self.obj, sun)
python
def sunRelation(self): """ Returns the relation of the object with the sun. """ sun = self.chart.getObject(const.SUN) return sunRelation(self.obj, sun)
[ "def", "sunRelation", "(", "self", ")", ":", "sun", "=", "self", ".", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "return", "sunRelation", "(", "self", ".", "obj", ",", "sun", ")" ]
Returns the relation of the object with the sun.
[ "Returns", "the", "relation", "of", "the", "object", "with", "the", "sun", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L174-L177
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.light
def light(self): """ Returns if object is augmenting or diminishing its light. """ sun = self.chart.getObject(const.SUN) return light(self.obj, sun)
python
def light(self): """ Returns if object is augmenting or diminishing its light. """ sun = self.chart.getObject(const.SUN) return light(self.obj, sun)
[ "def", "light", "(", "self", ")", ":", "sun", "=", "self", ".", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "return", "light", "(", "self", ".", "obj", ",", "sun", ")" ]
Returns if object is augmenting or diminishing its light.
[ "Returns", "if", "object", "is", "augmenting", "or", "diminishing", "its", "light", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L188-L194
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.orientality
def orientality(self): """ Returns the orientality of the object. """ sun = self.chart.getObject(const.SUN) return orientality(self.obj, sun)
python
def orientality(self): """ Returns the orientality of the object. """ sun = self.chart.getObject(const.SUN) return orientality(self.obj, sun)
[ "def", "orientality", "(", "self", ")", ":", "sun", "=", "self", ".", "chart", ".", "getObject", "(", "const", ".", "SUN", ")", "return", "orientality", "(", "self", ".", "obj", ",", "sun", ")" ]
Returns the orientality of the object.
[ "Returns", "the", "orientality", "of", "the", "object", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L199-L202
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.inHouseJoy
def inHouseJoy(self): """ Returns if the object is in its house of joy. """ house = self.house() return props.object.houseJoy[self.obj.id] == house.id
python
def inHouseJoy(self): """ Returns if the object is in its house of joy. """ house = self.house() return props.object.houseJoy[self.obj.id] == house.id
[ "def", "inHouseJoy", "(", "self", ")", ":", "house", "=", "self", ".", "house", "(", ")", "return", "props", ".", "object", ".", "houseJoy", "[", "self", ".", "obj", ".", "id", "]", "==", "house", ".", "id" ]
Returns if the object is in its house of joy.
[ "Returns", "if", "the", "object", "is", "in", "its", "house", "of", "joy", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L210-L213
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.inSignJoy
def inSignJoy(self): """ Returns if the object is in its sign of joy. """ return props.object.signJoy[self.obj.id] == self.obj.sign
python
def inSignJoy(self): """ Returns if the object is in its sign of joy. """ return props.object.signJoy[self.obj.id] == self.obj.sign
[ "def", "inSignJoy", "(", "self", ")", ":", "return", "props", ".", "object", ".", "signJoy", "[", "self", ".", "obj", ".", "id", "]", "==", "self", ".", "obj", ".", "sign" ]
Returns if the object is in its sign of joy.
[ "Returns", "if", "the", "object", "is", "in", "its", "sign", "of", "joy", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L215-L217
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.reMutualReceptions
def reMutualReceptions(self): """ Returns all mutual receptions with the object and other planets, indexed by planet ID. It only includes ruler and exaltation receptions. """ planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) mrs = {} for ID in planets: mr = self.dyn.reMutualReceptions(self.obj.id, ID) if mr: mrs[ID] = mr return mrs
python
def reMutualReceptions(self): """ Returns all mutual receptions with the object and other planets, indexed by planet ID. It only includes ruler and exaltation receptions. """ planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) mrs = {} for ID in planets: mr = self.dyn.reMutualReceptions(self.obj.id, ID) if mr: mrs[ID] = mr return mrs
[ "def", "reMutualReceptions", "(", "self", ")", ":", "planets", "=", "copy", "(", "const", ".", "LIST_SEVEN_PLANETS", ")", "planets", ".", "remove", "(", "self", ".", "obj", ".", "id", ")", "mrs", "=", "{", "}", "for", "ID", "in", "planets", ":", "mr", "=", "self", ".", "dyn", ".", "reMutualReceptions", "(", "self", ".", "obj", ".", "id", ",", "ID", ")", "if", "mr", ":", "mrs", "[", "ID", "]", "=", "mr", "return", "mrs" ]
Returns all mutual receptions with the object and other planets, indexed by planet ID. It only includes ruler and exaltation receptions.
[ "Returns", "all", "mutual", "receptions", "with", "the", "object", "and", "other", "planets", "indexed", "by", "planet", "ID", ".", "It", "only", "includes", "ruler", "and", "exaltation", "receptions", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L222-L235
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.eqMutualReceptions
def eqMutualReceptions(self): """ Returns a list with mutual receptions with the object and other planets, when the reception is the same for both (both ruler or both exaltation). It basically return a list with every ruler-ruler and exalt-exalt mutual receptions """ mrs = self.reMutualReceptions() res = [] for ID, receptions in mrs.items(): for pair in receptions: if pair[0] == pair[1]: res.append(pair[0]) return res
python
def eqMutualReceptions(self): """ Returns a list with mutual receptions with the object and other planets, when the reception is the same for both (both ruler or both exaltation). It basically return a list with every ruler-ruler and exalt-exalt mutual receptions """ mrs = self.reMutualReceptions() res = [] for ID, receptions in mrs.items(): for pair in receptions: if pair[0] == pair[1]: res.append(pair[0]) return res
[ "def", "eqMutualReceptions", "(", "self", ")", ":", "mrs", "=", "self", ".", "reMutualReceptions", "(", ")", "res", "=", "[", "]", "for", "ID", ",", "receptions", "in", "mrs", ".", "items", "(", ")", ":", "for", "pair", "in", "receptions", ":", "if", "pair", "[", "0", "]", "==", "pair", "[", "1", "]", ":", "res", ".", "append", "(", "pair", "[", "0", "]", ")", "return", "res" ]
Returns a list with mutual receptions with the object and other planets, when the reception is the same for both (both ruler or both exaltation). It basically return a list with every ruler-ruler and exalt-exalt mutual receptions
[ "Returns", "a", "list", "with", "mutual", "receptions", "with", "the", "object", "and", "other", "planets", "when", "the", "reception", "is", "the", "same", "for", "both", "(", "both", "ruler", "or", "both", "exaltation", ")", ".", "It", "basically", "return", "a", "list", "with", "every", "ruler", "-", "ruler", "and", "exalt", "-", "exalt", "mutual", "receptions" ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L237-L252
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.__aspectLists
def __aspectLists(self, IDs, aspList): """ Returns a list with the aspects that the object makes to the objects in IDs. It considers only conjunctions and other exact/applicative aspects if in aspList. """ res = [] for otherID in IDs: # Ignore same if otherID == self.obj.id: continue # Get aspects to the other object otherObj = self.chart.getObject(otherID) asp = aspects.getAspect(self.obj, otherObj, aspList) if asp.type == const.NO_ASPECT: continue elif asp.type == const.CONJUNCTION: res.append(asp.type) else: # Only exact or applicative aspects movement = asp.movement() if movement in [const.EXACT, const.APPLICATIVE]: res.append(asp.type) return res
python
def __aspectLists(self, IDs, aspList): """ Returns a list with the aspects that the object makes to the objects in IDs. It considers only conjunctions and other exact/applicative aspects if in aspList. """ res = [] for otherID in IDs: # Ignore same if otherID == self.obj.id: continue # Get aspects to the other object otherObj = self.chart.getObject(otherID) asp = aspects.getAspect(self.obj, otherObj, aspList) if asp.type == const.NO_ASPECT: continue elif asp.type == const.CONJUNCTION: res.append(asp.type) else: # Only exact or applicative aspects movement = asp.movement() if movement in [const.EXACT, const.APPLICATIVE]: res.append(asp.type) return res
[ "def", "__aspectLists", "(", "self", ",", "IDs", ",", "aspList", ")", ":", "res", "=", "[", "]", "for", "otherID", "in", "IDs", ":", "# Ignore same ", "if", "otherID", "==", "self", ".", "obj", ".", "id", ":", "continue", "# Get aspects to the other object", "otherObj", "=", "self", ".", "chart", ".", "getObject", "(", "otherID", ")", "asp", "=", "aspects", ".", "getAspect", "(", "self", ".", "obj", ",", "otherObj", ",", "aspList", ")", "if", "asp", ".", "type", "==", "const", ".", "NO_ASPECT", ":", "continue", "elif", "asp", ".", "type", "==", "const", ".", "CONJUNCTION", ":", "res", ".", "append", "(", "asp", ".", "type", ")", "else", ":", "# Only exact or applicative aspects", "movement", "=", "asp", ".", "movement", "(", ")", "if", "movement", "in", "[", "const", ".", "EXACT", ",", "const", ".", "APPLICATIVE", "]", ":", "res", ".", "append", "(", "asp", ".", "type", ")", "return", "res" ]
Returns a list with the aspects that the object makes to the objects in IDs. It considers only conjunctions and other exact/applicative aspects if in aspList.
[ "Returns", "a", "list", "with", "the", "aspects", "that", "the", "object", "makes", "to", "the", "objects", "in", "IDs", ".", "It", "considers", "only", "conjunctions", "and", "other", "exact", "/", "applicative", "aspects", "if", "in", "aspList", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L257-L285
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.aspectBenefics
def aspectBenefics(self): """ Returns a list with the good aspects the object makes to the benefics. """ benefics = [const.VENUS, const.JUPITER] return self.__aspectLists(benefics, aspList=[0, 60, 120])
python
def aspectBenefics(self): """ Returns a list with the good aspects the object makes to the benefics. """ benefics = [const.VENUS, const.JUPITER] return self.__aspectLists(benefics, aspList=[0, 60, 120])
[ "def", "aspectBenefics", "(", "self", ")", ":", "benefics", "=", "[", "const", ".", "VENUS", ",", "const", ".", "JUPITER", "]", "return", "self", ".", "__aspectLists", "(", "benefics", ",", "aspList", "=", "[", "0", ",", "60", ",", "120", "]", ")" ]
Returns a list with the good aspects the object makes to the benefics.
[ "Returns", "a", "list", "with", "the", "good", "aspects", "the", "object", "makes", "to", "the", "benefics", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L287-L293
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.aspectMalefics
def aspectMalefics(self): """ Returns a list with the bad aspects the object makes to the malefics. """ malefics = [const.MARS, const.SATURN] return self.__aspectLists(malefics, aspList=[0, 90, 180])
python
def aspectMalefics(self): """ Returns a list with the bad aspects the object makes to the malefics. """ malefics = [const.MARS, const.SATURN] return self.__aspectLists(malefics, aspList=[0, 90, 180])
[ "def", "aspectMalefics", "(", "self", ")", ":", "malefics", "=", "[", "const", ".", "MARS", ",", "const", ".", "SATURN", "]", "return", "self", ".", "__aspectLists", "(", "malefics", ",", "aspList", "=", "[", "0", ",", "90", ",", "180", "]", ")" ]
Returns a list with the bad aspects the object makes to the malefics.
[ "Returns", "a", "list", "with", "the", "bad", "aspects", "the", "object", "makes", "to", "the", "malefics", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L295-L301
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.__sepApp
def __sepApp(self, IDs, aspList): """ Returns true if the object last and next movement are separations and applications to objects in list IDs. It only considers aspects in aspList. This function is static since it does not test if the next application will be indeed perfected. It considers only a snapshot of the chart and not its astronomical movement. """ sep, app = self.dyn.immediateAspects(self.obj.id, aspList) if sep is None or app is None: return False else: sepCondition = sep['id'] in IDs appCondition = app['id'] in IDs return sepCondition == appCondition == True
python
def __sepApp(self, IDs, aspList): """ Returns true if the object last and next movement are separations and applications to objects in list IDs. It only considers aspects in aspList. This function is static since it does not test if the next application will be indeed perfected. It considers only a snapshot of the chart and not its astronomical movement. """ sep, app = self.dyn.immediateAspects(self.obj.id, aspList) if sep is None or app is None: return False else: sepCondition = sep['id'] in IDs appCondition = app['id'] in IDs return sepCondition == appCondition == True
[ "def", "__sepApp", "(", "self", ",", "IDs", ",", "aspList", ")", ":", "sep", ",", "app", "=", "self", ".", "dyn", ".", "immediateAspects", "(", "self", ".", "obj", ".", "id", ",", "aspList", ")", "if", "sep", "is", "None", "or", "app", "is", "None", ":", "return", "False", "else", ":", "sepCondition", "=", "sep", "[", "'id'", "]", "in", "IDs", "appCondition", "=", "app", "[", "'id'", "]", "in", "IDs", "return", "sepCondition", "==", "appCondition", "==", "True" ]
Returns true if the object last and next movement are separations and applications to objects in list IDs. It only considers aspects in aspList. This function is static since it does not test if the next application will be indeed perfected. It considers only a snapshot of the chart and not its astronomical movement.
[ "Returns", "true", "if", "the", "object", "last", "and", "next", "movement", "are", "separations", "and", "applications", "to", "objects", "in", "list", "IDs", ".", "It", "only", "considers", "aspects", "in", "aspList", ".", "This", "function", "is", "static", "since", "it", "does", "not", "test", "if", "the", "next", "application", "will", "be", "indeed", "perfected", ".", "It", "considers", "only", "a", "snapshot", "of", "the", "chart", "and", "not", "its", "astronomical", "movement", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L306-L322
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.isAuxilied
def isAuxilied(self): """ Returns if the object is separating and applying to a benefic considering good aspects. """ benefics = [const.VENUS, const.JUPITER] return self.__sepApp(benefics, aspList=[0, 60, 120])
python
def isAuxilied(self): """ Returns if the object is separating and applying to a benefic considering good aspects. """ benefics = [const.VENUS, const.JUPITER] return self.__sepApp(benefics, aspList=[0, 60, 120])
[ "def", "isAuxilied", "(", "self", ")", ":", "benefics", "=", "[", "const", ".", "VENUS", ",", "const", ".", "JUPITER", "]", "return", "self", ".", "__sepApp", "(", "benefics", ",", "aspList", "=", "[", "0", ",", "60", ",", "120", "]", ")" ]
Returns if the object is separating and applying to a benefic considering good aspects.
[ "Returns", "if", "the", "object", "is", "separating", "and", "applying", "to", "a", "benefic", "considering", "good", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L324-L330
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.isSurrounded
def isSurrounded(self): """ Returns if the object is separating and applying to a malefic considering bad aspects. """ malefics = [const.MARS, const.SATURN] return self.__sepApp(malefics, aspList=[0, 90, 180])
python
def isSurrounded(self): """ Returns if the object is separating and applying to a malefic considering bad aspects. """ malefics = [const.MARS, const.SATURN] return self.__sepApp(malefics, aspList=[0, 90, 180])
[ "def", "isSurrounded", "(", "self", ")", ":", "malefics", "=", "[", "const", ".", "MARS", ",", "const", ".", "SATURN", "]", "return", "self", ".", "__sepApp", "(", "malefics", ",", "aspList", "=", "[", "0", ",", "90", ",", "180", "]", ")" ]
Returns if the object is separating and applying to a malefic considering bad aspects.
[ "Returns", "if", "the", "object", "is", "separating", "and", "applying", "to", "a", "malefic", "considering", "bad", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L332-L338
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.isConjNorthNode
def isConjNorthNode(self): """ Returns if object is conjunct north node. """ node = self.chart.getObject(const.NORTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
python
def isConjNorthNode(self): """ Returns if object is conjunct north node. """ node = self.chart.getObject(const.NORTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
[ "def", "isConjNorthNode", "(", "self", ")", ":", "node", "=", "self", ".", "chart", ".", "getObject", "(", "const", ".", "NORTH_NODE", ")", "return", "aspects", ".", "hasAspect", "(", "self", ".", "obj", ",", "node", ",", "aspList", "=", "[", "0", "]", ")" ]
Returns if object is conjunct north node.
[ "Returns", "if", "object", "is", "conjunct", "north", "node", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L343-L346
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.isConjSouthNode
def isConjSouthNode(self): """ Returns if object is conjunct south node. """ node = self.chart.getObject(const.SOUTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
python
def isConjSouthNode(self): """ Returns if object is conjunct south node. """ node = self.chart.getObject(const.SOUTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
[ "def", "isConjSouthNode", "(", "self", ")", ":", "node", "=", "self", ".", "chart", ".", "getObject", "(", "const", ".", "SOUTH_NODE", ")", "return", "aspects", ".", "hasAspect", "(", "self", ".", "obj", ",", "node", ",", "aspList", "=", "[", "0", "]", ")" ]
Returns if object is conjunct south node.
[ "Returns", "if", "object", "is", "conjunct", "south", "node", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L348-L351
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.isFeral
def isFeral(self): """ Returns true if the object does not have any aspects. """ planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) for otherID in planets: otherObj = self.chart.getObject(otherID) if aspects.hasAspect(self.obj, otherObj, const.MAJOR_ASPECTS): return False return True
python
def isFeral(self): """ Returns true if the object does not have any aspects. """ planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) for otherID in planets: otherObj = self.chart.getObject(otherID) if aspects.hasAspect(self.obj, otherObj, const.MAJOR_ASPECTS): return False return True
[ "def", "isFeral", "(", "self", ")", ":", "planets", "=", "copy", "(", "const", ".", "LIST_SEVEN_PLANETS", ")", "planets", ".", "remove", "(", "self", ".", "obj", ".", "id", ")", "for", "otherID", "in", "planets", ":", "otherObj", "=", "self", ".", "chart", ".", "getObject", "(", "otherID", ")", "if", "aspects", ".", "hasAspect", "(", "self", ".", "obj", ",", "otherObj", ",", "const", ".", "MAJOR_ASPECTS", ")", ":", "return", "False", "return", "True" ]
Returns true if the object does not have any aspects.
[ "Returns", "true", "if", "the", "object", "does", "not", "have", "any", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L360-L371
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.getScoreProperties
def getScoreProperties(self): """ Returns the accidental dignity score of the object as dict. """ obj = self.obj score = {} # Peregrine isPeregrine = essential.isPeregrine(obj.id, obj.sign, obj.signlon) score['peregrine'] = -5 if isPeregrine else 0 # Ruler-Ruler and Exalt-Exalt mutual receptions mr = self.eqMutualReceptions() score['mr_ruler'] = +5 if 'ruler' in mr else 0 score['mr_exalt'] = +4 if 'exalt' in mr else 0 # House scores score['house'] = self.houseScore() # Joys score['joy_sign'] = +3 if self.inSignJoy() else 0 score['joy_house'] = +2 if self.inHouseJoy() else 0 # Relations with sun score['cazimi'] = +5 if self.isCazimi() else 0 score['combust'] = -6 if self.isCombust() else 0 score['under_sun'] = -4 if self.isUnderSun() else 0 score['no_under_sun'] = 0 if obj.id != const.SUN and not self.sunRelation(): score['no_under_sun'] = +5 # Light score['light'] = 0 if obj.id != const.SUN: score['light'] = +1 if self.isAugmentingLight() else -1 # Orientality score['orientality'] = 0 if obj.id in [const.SATURN, const.JUPITER, const.MARS]: score['orientality'] = +2 if self.isOriental() else -2 elif obj.id in [const.VENUS, const.MERCURY, const.MOON]: score['orientality'] = -2 if self.isOriental() else +2 # Moon nodes score['north_node'] = -3 if self.isConjNorthNode() else 0 score['south_node'] = -5 if self.isConjSouthNode() else 0 # Direction and speed score['direction'] = 0 if obj.id not in [const.SUN, const.MOON]: score['direction'] = +4 if obj.isDirect() else -5 score['speed'] = +2 if obj.isFast() else -2 # Aspects to benefics aspBen = self.aspectBenefics() score['benefic_asp0'] = +5 if const.CONJUNCTION in aspBen else 0 score['benefic_asp120'] = +4 if const.TRINE in aspBen else 0 score['benefic_asp60'] = +3 if const.SEXTILE in aspBen else 0 # Aspects to malefics aspMal = self.aspectMalefics() score['malefic_asp0'] = -5 if const.CONJUNCTION in aspMal else 0 score['malefic_asp180'] = -4 if const.OPPOSITION in aspMal else 0 score['malefic_asp90'] = -3 if const.SQUARE in aspMal else 0 # Auxily and Surround score['auxilied'] = +5 if self.isAuxilied() else 0 score['surround'] = -5 if self.isSurrounded() else 0 # Voc and Feral score['feral'] = -3 if self.isFeral() else 0 score['void'] = -2 if (self.isVoc() and score['feral'] == 0) else 0 # Haiz haiz = self.haiz() score['haiz'] = 0 if haiz == HAIZ: score['haiz'] = +3 elif haiz == CHAIZ: score['haiz'] = -2 # Moon via combusta score['viacombusta'] = 0 if obj.id == const.MOON and viaCombusta(obj): score['viacombusta'] = -2 return score
python
def getScoreProperties(self): """ Returns the accidental dignity score of the object as dict. """ obj = self.obj score = {} # Peregrine isPeregrine = essential.isPeregrine(obj.id, obj.sign, obj.signlon) score['peregrine'] = -5 if isPeregrine else 0 # Ruler-Ruler and Exalt-Exalt mutual receptions mr = self.eqMutualReceptions() score['mr_ruler'] = +5 if 'ruler' in mr else 0 score['mr_exalt'] = +4 if 'exalt' in mr else 0 # House scores score['house'] = self.houseScore() # Joys score['joy_sign'] = +3 if self.inSignJoy() else 0 score['joy_house'] = +2 if self.inHouseJoy() else 0 # Relations with sun score['cazimi'] = +5 if self.isCazimi() else 0 score['combust'] = -6 if self.isCombust() else 0 score['under_sun'] = -4 if self.isUnderSun() else 0 score['no_under_sun'] = 0 if obj.id != const.SUN and not self.sunRelation(): score['no_under_sun'] = +5 # Light score['light'] = 0 if obj.id != const.SUN: score['light'] = +1 if self.isAugmentingLight() else -1 # Orientality score['orientality'] = 0 if obj.id in [const.SATURN, const.JUPITER, const.MARS]: score['orientality'] = +2 if self.isOriental() else -2 elif obj.id in [const.VENUS, const.MERCURY, const.MOON]: score['orientality'] = -2 if self.isOriental() else +2 # Moon nodes score['north_node'] = -3 if self.isConjNorthNode() else 0 score['south_node'] = -5 if self.isConjSouthNode() else 0 # Direction and speed score['direction'] = 0 if obj.id not in [const.SUN, const.MOON]: score['direction'] = +4 if obj.isDirect() else -5 score['speed'] = +2 if obj.isFast() else -2 # Aspects to benefics aspBen = self.aspectBenefics() score['benefic_asp0'] = +5 if const.CONJUNCTION in aspBen else 0 score['benefic_asp120'] = +4 if const.TRINE in aspBen else 0 score['benefic_asp60'] = +3 if const.SEXTILE in aspBen else 0 # Aspects to malefics aspMal = self.aspectMalefics() score['malefic_asp0'] = -5 if const.CONJUNCTION in aspMal else 0 score['malefic_asp180'] = -4 if const.OPPOSITION in aspMal else 0 score['malefic_asp90'] = -3 if const.SQUARE in aspMal else 0 # Auxily and Surround score['auxilied'] = +5 if self.isAuxilied() else 0 score['surround'] = -5 if self.isSurrounded() else 0 # Voc and Feral score['feral'] = -3 if self.isFeral() else 0 score['void'] = -2 if (self.isVoc() and score['feral'] == 0) else 0 # Haiz haiz = self.haiz() score['haiz'] = 0 if haiz == HAIZ: score['haiz'] = +3 elif haiz == CHAIZ: score['haiz'] = -2 # Moon via combusta score['viacombusta'] = 0 if obj.id == const.MOON and viaCombusta(obj): score['viacombusta'] = -2 return score
[ "def", "getScoreProperties", "(", "self", ")", ":", "obj", "=", "self", ".", "obj", "score", "=", "{", "}", "# Peregrine", "isPeregrine", "=", "essential", ".", "isPeregrine", "(", "obj", ".", "id", ",", "obj", ".", "sign", ",", "obj", ".", "signlon", ")", "score", "[", "'peregrine'", "]", "=", "-", "5", "if", "isPeregrine", "else", "0", "# Ruler-Ruler and Exalt-Exalt mutual receptions", "mr", "=", "self", ".", "eqMutualReceptions", "(", ")", "score", "[", "'mr_ruler'", "]", "=", "+", "5", "if", "'ruler'", "in", "mr", "else", "0", "score", "[", "'mr_exalt'", "]", "=", "+", "4", "if", "'exalt'", "in", "mr", "else", "0", "# House scores", "score", "[", "'house'", "]", "=", "self", ".", "houseScore", "(", ")", "# Joys", "score", "[", "'joy_sign'", "]", "=", "+", "3", "if", "self", ".", "inSignJoy", "(", ")", "else", "0", "score", "[", "'joy_house'", "]", "=", "+", "2", "if", "self", ".", "inHouseJoy", "(", ")", "else", "0", "# Relations with sun", "score", "[", "'cazimi'", "]", "=", "+", "5", "if", "self", ".", "isCazimi", "(", ")", "else", "0", "score", "[", "'combust'", "]", "=", "-", "6", "if", "self", ".", "isCombust", "(", ")", "else", "0", "score", "[", "'under_sun'", "]", "=", "-", "4", "if", "self", ".", "isUnderSun", "(", ")", "else", "0", "score", "[", "'no_under_sun'", "]", "=", "0", "if", "obj", ".", "id", "!=", "const", ".", "SUN", "and", "not", "self", ".", "sunRelation", "(", ")", ":", "score", "[", "'no_under_sun'", "]", "=", "+", "5", "# Light", "score", "[", "'light'", "]", "=", "0", "if", "obj", ".", "id", "!=", "const", ".", "SUN", ":", "score", "[", "'light'", "]", "=", "+", "1", "if", "self", ".", "isAugmentingLight", "(", ")", "else", "-", "1", "# Orientality", "score", "[", "'orientality'", "]", "=", "0", "if", "obj", ".", "id", "in", "[", "const", ".", "SATURN", ",", "const", ".", "JUPITER", ",", "const", ".", "MARS", "]", ":", "score", "[", "'orientality'", "]", "=", "+", "2", "if", "self", ".", "isOriental", "(", ")", "else", "-", "2", "elif", "obj", ".", "id", "in", "[", "const", ".", "VENUS", ",", "const", ".", "MERCURY", ",", "const", ".", "MOON", "]", ":", "score", "[", "'orientality'", "]", "=", "-", "2", "if", "self", ".", "isOriental", "(", ")", "else", "+", "2", "# Moon nodes", "score", "[", "'north_node'", "]", "=", "-", "3", "if", "self", ".", "isConjNorthNode", "(", ")", "else", "0", "score", "[", "'south_node'", "]", "=", "-", "5", "if", "self", ".", "isConjSouthNode", "(", ")", "else", "0", "# Direction and speed", "score", "[", "'direction'", "]", "=", "0", "if", "obj", ".", "id", "not", "in", "[", "const", ".", "SUN", ",", "const", ".", "MOON", "]", ":", "score", "[", "'direction'", "]", "=", "+", "4", "if", "obj", ".", "isDirect", "(", ")", "else", "-", "5", "score", "[", "'speed'", "]", "=", "+", "2", "if", "obj", ".", "isFast", "(", ")", "else", "-", "2", "# Aspects to benefics", "aspBen", "=", "self", ".", "aspectBenefics", "(", ")", "score", "[", "'benefic_asp0'", "]", "=", "+", "5", "if", "const", ".", "CONJUNCTION", "in", "aspBen", "else", "0", "score", "[", "'benefic_asp120'", "]", "=", "+", "4", "if", "const", ".", "TRINE", "in", "aspBen", "else", "0", "score", "[", "'benefic_asp60'", "]", "=", "+", "3", "if", "const", ".", "SEXTILE", "in", "aspBen", "else", "0", "# Aspects to malefics", "aspMal", "=", "self", ".", "aspectMalefics", "(", ")", "score", "[", "'malefic_asp0'", "]", "=", "-", "5", "if", "const", ".", "CONJUNCTION", "in", "aspMal", "else", "0", "score", "[", "'malefic_asp180'", "]", "=", "-", "4", "if", "const", ".", "OPPOSITION", "in", "aspMal", "else", "0", "score", "[", "'malefic_asp90'", "]", "=", "-", "3", "if", "const", ".", "SQUARE", "in", "aspMal", "else", "0", "# Auxily and Surround", "score", "[", "'auxilied'", "]", "=", "+", "5", "if", "self", ".", "isAuxilied", "(", ")", "else", "0", "score", "[", "'surround'", "]", "=", "-", "5", "if", "self", ".", "isSurrounded", "(", ")", "else", "0", "# Voc and Feral", "score", "[", "'feral'", "]", "=", "-", "3", "if", "self", ".", "isFeral", "(", ")", "else", "0", "score", "[", "'void'", "]", "=", "-", "2", "if", "(", "self", ".", "isVoc", "(", ")", "and", "score", "[", "'feral'", "]", "==", "0", ")", "else", "0", "# Haiz", "haiz", "=", "self", ".", "haiz", "(", ")", "score", "[", "'haiz'", "]", "=", "0", "if", "haiz", "==", "HAIZ", ":", "score", "[", "'haiz'", "]", "=", "+", "3", "elif", "haiz", "==", "CHAIZ", ":", "score", "[", "'haiz'", "]", "=", "-", "2", "# Moon via combusta", "score", "[", "'viacombusta'", "]", "=", "0", "if", "obj", ".", "id", "==", "const", ".", "MOON", "and", "viaCombusta", "(", "obj", ")", ":", "score", "[", "'viacombusta'", "]", "=", "-", "2", "return", "score" ]
Returns the accidental dignity score of the object as dict.
[ "Returns", "the", "accidental", "dignity", "score", "of", "the", "object", "as", "dict", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L380-L467
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.getActiveProperties
def getActiveProperties(self): """ Returns the non-zero accidental dignities. """ score = self.getScoreProperties() return {key: value for (key, value) in score.items() if value != 0}
python
def getActiveProperties(self): """ Returns the non-zero accidental dignities. """ score = self.getScoreProperties() return {key: value for (key, value) in score.items() if value != 0}
[ "def", "getActiveProperties", "(", "self", ")", ":", "score", "=", "self", ".", "getScoreProperties", "(", ")", "return", "{", "key", ":", "value", "for", "(", "key", ",", "value", ")", "in", "score", ".", "items", "(", ")", "if", "value", "!=", "0", "}" ]
Returns the non-zero accidental dignities.
[ "Returns", "the", "non", "-", "zero", "accidental", "dignities", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L469-L473
flatangle/flatlib
flatlib/dignities/accidental.py
AccidentalDignity.score
def score(self): """ Returns the sum of the accidental dignities score. """ if not self.scoreProperties: self.scoreProperties = self.getScoreProperties() return sum(self.scoreProperties.values())
python
def score(self): """ Returns the sum of the accidental dignities score. """ if not self.scoreProperties: self.scoreProperties = self.getScoreProperties() return sum(self.scoreProperties.values())
[ "def", "score", "(", "self", ")", ":", "if", "not", "self", ".", "scoreProperties", ":", "self", ".", "scoreProperties", "=", "self", ".", "getScoreProperties", "(", ")", "return", "sum", "(", "self", ".", "scoreProperties", ".", "values", "(", ")", ")" ]
Returns the sum of the accidental dignities score.
[ "Returns", "the", "sum", "of", "the", "accidental", "dignities", "score", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L475-L482
flatangle/flatlib
flatlib/object.py
GenericObject.fromDict
def fromDict(cls, _dict): """ Builds instance from dictionary of properties. """ obj = cls() obj.__dict__.update(_dict) return obj
python
def fromDict(cls, _dict): """ Builds instance from dictionary of properties. """ obj = cls() obj.__dict__.update(_dict) return obj
[ "def", "fromDict", "(", "cls", ",", "_dict", ")", ":", "obj", "=", "cls", "(", ")", "obj", ".", "__dict__", ".", "update", "(", "_dict", ")", "return", "obj" ]
Builds instance from dictionary of properties.
[ "Builds", "instance", "from", "dictionary", "of", "properties", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L39-L43
flatangle/flatlib
flatlib/object.py
GenericObject.eqCoords
def eqCoords(self, zerolat=False): """ Returns the Equatorial Coordinates of this object. Receives a boolean parameter to consider a zero latitude. """ lat = 0.0 if zerolat else self.lat return utils.eqCoords(self.lon, lat)
python
def eqCoords(self, zerolat=False): """ Returns the Equatorial Coordinates of this object. Receives a boolean parameter to consider a zero latitude. """ lat = 0.0 if zerolat else self.lat return utils.eqCoords(self.lon, lat)
[ "def", "eqCoords", "(", "self", ",", "zerolat", "=", "False", ")", ":", "lat", "=", "0.0", "if", "zerolat", "else", "self", ".", "lat", "return", "utils", ".", "eqCoords", "(", "self", ".", "lon", ",", "lat", ")" ]
Returns the Equatorial Coordinates of this object. Receives a boolean parameter to consider a zero latitude.
[ "Returns", "the", "Equatorial", "Coordinates", "of", "this", "object", ".", "Receives", "a", "boolean", "parameter", "to", "consider", "a", "zero", "latitude", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L66-L72
flatangle/flatlib
flatlib/object.py
GenericObject.relocate
def relocate(self, lon): """ Relocates this object to a new longitude. """ self.lon = angle.norm(lon) self.signlon = self.lon % 30 self.sign = const.LIST_SIGNS[int(self.lon / 30.0)]
python
def relocate(self, lon): """ Relocates this object to a new longitude. """ self.lon = angle.norm(lon) self.signlon = self.lon % 30 self.sign = const.LIST_SIGNS[int(self.lon / 30.0)]
[ "def", "relocate", "(", "self", ",", "lon", ")", ":", "self", ".", "lon", "=", "angle", ".", "norm", "(", "lon", ")", "self", ".", "signlon", "=", "self", ".", "lon", "%", "30", "self", ".", "sign", "=", "const", ".", "LIST_SIGNS", "[", "int", "(", "self", ".", "lon", "/", "30.0", ")", "]" ]
Relocates this object to a new longitude.
[ "Relocates", "this", "object", "to", "a", "new", "longitude", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L76-L80
flatangle/flatlib
flatlib/object.py
GenericObject.antiscia
def antiscia(self): """ Returns antiscia object. """ obj = self.copy() obj.type = const.OBJ_GENERIC obj.relocate(360 - obj.lon + 180) return obj
python
def antiscia(self): """ Returns antiscia object. """ obj = self.copy() obj.type = const.OBJ_GENERIC obj.relocate(360 - obj.lon + 180) return obj
[ "def", "antiscia", "(", "self", ")", ":", "obj", "=", "self", ".", "copy", "(", ")", "obj", ".", "type", "=", "const", ".", "OBJ_GENERIC", "obj", ".", "relocate", "(", "360", "-", "obj", ".", "lon", "+", "180", ")", "return", "obj" ]
Returns antiscia object.
[ "Returns", "antiscia", "object", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L82-L87
flatangle/flatlib
flatlib/object.py
Object.movement
def movement(self): """ Returns if this object is direct, retrograde or stationary. """ if abs(self.lonspeed) < 0.0003: return const.STATIONARY elif self.lonspeed > 0: return const.DIRECT else: return const.RETROGRADE
python
def movement(self): """ Returns if this object is direct, retrograde or stationary. """ if abs(self.lonspeed) < 0.0003: return const.STATIONARY elif self.lonspeed > 0: return const.DIRECT else: return const.RETROGRADE
[ "def", "movement", "(", "self", ")", ":", "if", "abs", "(", "self", ".", "lonspeed", ")", "<", "0.0003", ":", "return", "const", ".", "STATIONARY", "elif", "self", ".", "lonspeed", ">", "0", ":", "return", "const", ".", "DIRECT", "else", ":", "return", "const", ".", "RETROGRADE" ]
Returns if this object is direct, retrograde or stationary.
[ "Returns", "if", "this", "object", "is", "direct", "retrograde", "or", "stationary", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L131-L141
flatangle/flatlib
flatlib/object.py
House.inHouse
def inHouse(self, lon): """ Returns if a longitude belongs to this house. """ dist = angle.distance(self.lon + House._OFFSET, lon) return dist < self.size
python
def inHouse(self, lon): """ Returns if a longitude belongs to this house. """ dist = angle.distance(self.lon + House._OFFSET, lon) return dist < self.size
[ "def", "inHouse", "(", "self", ",", "lon", ")", ":", "dist", "=", "angle", ".", "distance", "(", "self", ".", "lon", "+", "House", ".", "_OFFSET", ",", "lon", ")", "return", "dist", "<", "self", ".", "size" ]
Returns if a longitude belongs to this house.
[ "Returns", "if", "a", "longitude", "belongs", "to", "this", "house", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L219-L222
flatangle/flatlib
flatlib/object.py
FixedStar.orb
def orb(self): """ Returns the orb of this fixed star. """ for (mag, orb) in FixedStar._ORBS: if self.mag < mag: return orb return 0.5
python
def orb(self): """ Returns the orb of this fixed star. """ for (mag, orb) in FixedStar._ORBS: if self.mag < mag: return orb return 0.5
[ "def", "orb", "(", "self", ")", ":", "for", "(", "mag", ",", "orb", ")", "in", "FixedStar", ".", "_ORBS", ":", "if", "self", ".", "mag", "<", "mag", ":", "return", "orb", "return", "0.5" ]
Returns the orb of this fixed star.
[ "Returns", "the", "orb", "of", "this", "fixed", "star", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L253-L258
flatangle/flatlib
flatlib/object.py
FixedStar.aspects
def aspects(self, obj): """ Returns true if this star aspects another object. Fixed stars only aspect by conjunctions. """ dist = angle.closestdistance(self.lon, obj.lon) return abs(dist) < self.orb()
python
def aspects(self, obj): """ Returns true if this star aspects another object. Fixed stars only aspect by conjunctions. """ dist = angle.closestdistance(self.lon, obj.lon) return abs(dist) < self.orb()
[ "def", "aspects", "(", "self", ",", "obj", ")", ":", "dist", "=", "angle", ".", "closestdistance", "(", "self", ".", "lon", ",", "obj", ".", "lon", ")", "return", "abs", "(", "dist", ")", "<", "self", ".", "orb", "(", ")" ]
Returns true if this star aspects another object. Fixed stars only aspect by conjunctions.
[ "Returns", "true", "if", "this", "star", "aspects", "another", "object", ".", "Fixed", "stars", "only", "aspect", "by", "conjunctions", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/object.py#L262-L268
flatangle/flatlib
flatlib/lists.py
ObjectList.getObjectsInHouse
def getObjectsInHouse(self, house): """ Returns a list with all objects in a house. """ res = [obj for obj in self if house.hasObject(obj)] return ObjectList(res)
python
def getObjectsInHouse(self, house): """ Returns a list with all objects in a house. """ res = [obj for obj in self if house.hasObject(obj)] return ObjectList(res)
[ "def", "getObjectsInHouse", "(", "self", ",", "house", ")", ":", "res", "=", "[", "obj", "for", "obj", "in", "self", "if", "house", ".", "hasObject", "(", "obj", ")", "]", "return", "ObjectList", "(", "res", ")" ]
Returns a list with all objects in a house.
[ "Returns", "a", "list", "with", "all", "objects", "in", "a", "house", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/lists.py#L63-L66
flatangle/flatlib
flatlib/lists.py
ObjectList.getObjectsAspecting
def getObjectsAspecting(self, point, aspList): """ Returns a list of objects aspecting a point considering a list of possible aspects. """ res = [] for obj in self: if obj.isPlanet() and aspects.isAspecting(obj, point, aspList): res.append(obj) return ObjectList(res)
python
def getObjectsAspecting(self, point, aspList): """ Returns a list of objects aspecting a point considering a list of possible aspects. """ res = [] for obj in self: if obj.isPlanet() and aspects.isAspecting(obj, point, aspList): res.append(obj) return ObjectList(res)
[ "def", "getObjectsAspecting", "(", "self", ",", "point", ",", "aspList", ")", ":", "res", "=", "[", "]", "for", "obj", "in", "self", ":", "if", "obj", ".", "isPlanet", "(", ")", "and", "aspects", ".", "isAspecting", "(", "obj", ",", "point", ",", "aspList", ")", ":", "res", ".", "append", "(", "obj", ")", "return", "ObjectList", "(", "res", ")" ]
Returns a list of objects aspecting a point considering a list of possible aspects.
[ "Returns", "a", "list", "of", "objects", "aspecting", "a", "point", "considering", "a", "list", "of", "possible", "aspects", "." ]
train
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/lists.py#L68-L77