for any info/changes follow me: @nickmilon
Hellas.Athens module¶
This module contains only scientific functions and it is named after the ancient city of Athens and Athena the godness of science
-
Hellas.Athens.
ngrams
(slice_able, n)[source]¶ produces ngram of an object :param obj slice_able: any slicable object i.e string list etc :param int n: n-th grams
Returns: an iterator of ngram tuples (actually returns a list in Python 2.7) but always treat it as iterator for python 3+ compatibility)
Example: >>> ngrams("The quick brown fox jumps over the lazy dog", 2) [('T', 'h'), ('h', 'e'), ('e', ' '), (' ', 'q'), ('q', 'u'), ('u', 'i'), ('i', 'c') .... ]
See also
-
Hellas.Athens.
bigrams
(slice_able)[source]¶ produces bigrams same as ngrams (x, 2) but more efficient
Returns: - an iterator of bigram tuples
(actually returns a list in Python 2.7) but always treat it as iterator for python 3+ compatibility)
See also
-
Hellas.Athens.
haversine
(lon1, lat1, lon2, lat2)[source]¶ Calculate the great circle distance between two points on earth in Kilometers on the earth (specified in decimal degrees)
See also
Parameters: - lon1 (float) – longitude of first place (decimal degrees)
- lat1 (float) – latitude of first place (decimal degrees)
- lon2 (float) – longitude of second place (decimal degrees)
- lat2 (float) – latitude of second place (decimal degrees)
Example: >>> London_long=-0.126 ; London_lat=51.50; Paris_long = 2.350; Paris_lat = 48.856 >>> haversine(London_long, London_lat, Paris_long, Paris_lat) 342.55375272454864
Returns: float distance in Kilometers
-
Hellas.Athens.
distance_points
(point1, point2)[source]¶ just a wrapper for
haversine()
Parameters: - point1 (tuple_or_list) – (longitude, latitude) in decimal degrees
- point2 (tuple_or_list) – (longitude, latitude) in decimal degrees
Example: >>> London = (-0.1262, 51.50,); Paris = (2.350, 48.856) >>> distance_points(London, Paris) 342.55
-
Hellas.Athens.
bit_set
(offset, int_tp=0)[source]¶ sets bit of int_tp at offset to 1
Parameters: - offset (int) – position offset
- int_tp (int) – original integer or long (defaults to 0)
Returns: a new int or long
Example: >>> bit_set(2) 4 >>> bit_set(2,4) 4 # because bit already set >>> bin(bit_set(16)) '0b10000000000000000'