OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
omnisci._utils Namespace Reference

Functions

def seconds_to_time
 
def time_to_seconds
 
def datetime_in_precisions
 
def date_to_seconds
 

Variables

dictionary mapd_to_slot
 
dictionary mapd_to_na
 

Function Documentation

def omnisci._utils.date_to_seconds (   arr)
Converts date into seconds

Definition at line 36 of file _utils.py.

36 
37 def date_to_seconds(arr):
38  """Converts date into seconds"""
39 
40  return arr.apply(lambda x: np.datetime64(x, "s").astype(int))
41 
def date_to_seconds
Definition: _utils.py:36
def omnisci._utils.datetime_in_precisions (   epoch,
  precision 
)
Convert epoch time value into s, ms, us, ns

Definition at line 19 of file _utils.py.

Referenced by omnisci._parsers._format_result_timestamp().

19 
20 def datetime_in_precisions(epoch, precision):
21  """Convert epoch time value into s, ms, us, ns"""
22  base = datetime.datetime(1970, 1, 1)
23  if precision == 0:
24  return base + datetime.timedelta(seconds=epoch)
25  elif precision == 3:
26  seconds, modulus = divmod(epoch, 1000)
27  return base + datetime.timedelta(seconds=seconds, milliseconds=modulus)
28  elif precision == 6:
29  seconds, modulus = divmod(epoch, 1000000)
30  return base + datetime.timedelta(seconds=seconds, microseconds=modulus)
31  elif precision == 9:
32  return np.datetime64(epoch, 'ns')
33  else:
34  raise TypeError("Invalid timestamp precision: {}".format(precision))
35 
def datetime_in_precisions
Definition: _utils.py:19

+ Here is the caller graph for this function:

def omnisci._utils.seconds_to_time (   seconds)
Convert seconds since midnight to a datetime.time

Definition at line 5 of file _utils.py.

Referenced by omnisci._parsers._format_result_time().

5 
6 def seconds_to_time(seconds):
7  """Convert seconds since midnight to a datetime.time"""
8  m, s = divmod(seconds, 60)
9  h, m = divmod(m, 60)
10  return datetime.time(h, m, s)
11 
def seconds_to_time
Definition: _utils.py:5

+ Here is the caller graph for this function:

def omnisci._utils.time_to_seconds (   time)
Convert a datetime.time to seconds since midnight

Definition at line 12 of file _utils.py.

12 
13 def time_to_seconds(time):
14  """Convert a datetime.time to seconds since midnight"""
15  if time is None:
16  return None
17  return 3600 * time.hour + 60 * time.minute + time.second
18 
def time_to_seconds
Definition: _utils.py:12

Variable Documentation

dictionary omnisci._utils.mapd_to_na
Initial value:
1 = {
2  'BOOL': -128,
3  'BOOLEAN': -128,
4  'SMALLINT': -32768,
5  'INT': -2147483648,
6  'INTEGER': -2147483648,
7  'BIGINT': -9223372036854775808,
8  'FLOAT': 0,
9  'DECIMAL': 0,
10  'DOUBLE': 0,
11  'TIMESTAMP': -9223372036854775808,
12  'DATE': -9223372036854775808,
13  'TIME': -9223372036854775808,
14  'STR': '',
15  'POINT': '',
16  'LINESTRING': '',
17  'POLYGON': '',
18  'MULTIPOLYGON': '',
19  'TINYINT': -128,
20  'GEOMETRY': '',
21  'GEOGRAPHY': '',
22 }

Definition at line 66 of file _utils.py.

dictionary omnisci._utils.mapd_to_slot
Initial value:
1 = {
2  'BOOL': 'int_col',
3  'BOOLEAN': 'int_col',
4  'SMALLINT': 'int_col',
5  'INT': 'int_col',
6  'INTEGER': 'int_col',
7  'BIGINT': 'int_col',
8  'FLOAT': 'real_col',
9  'DECIMAL': 'int_col',
10  'DOUBLE': 'real_col',
11  'TIMESTAMP': 'int_col',
12  'DATE': 'int_col',
13  'TIME': 'int_col',
14  'STR': 'str_col',
15  'POINT': 'str_col',
16  'LINESTRING': 'str_col',
17  'POLYGON': 'str_col',
18  'MULTIPOLYGON': 'str_col',
19  'TINYINT': 'int_col',
20  'GEOMETRY': 'str_col',
21  'GEOGRAPHY': 'str_col',
22 }

Definition at line 42 of file _utils.py.