Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit bf88766

Browse files
committed
[FIX] CI PEP257 and FLAKE8 issues
1 parent f22ddff commit bf88766

File tree

3 files changed

+39
-27
lines changed

3 files changed

+39
-27
lines changed

influxdb/line_protocol.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212
from six import iteritems, binary_type, text_type, integer_types, PY2
1313

1414
import pandas as pd # Provide for ns timestamps
15-
import numpy as np # Provided for accurate precision_factor conversion
15+
import numpy as np # Provided for accurate precision_factor conversion
1616

1717
EPOCH = pd.Timestamp(0, tz='UTC')
1818

19-
# Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation
20-
# Example : the issue is only observable with nanosecond resolution values are greater than 895ns
19+
# Precisions factors must be int for correct calculation to ints.
20+
# if precision is float the result of a floor calc is an approximation
21+
# Example : the issue is only observable with nanosecond resolution
22+
# values are greater than 895ns
2123
# ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00')
2224
# ts_ns = np.int64(ts.value)
2325
# # For conversion to microsecond
2426
# precision_factor=1e3
2527
# expected_ts_us = 1357081855123456
26-
# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457
27-
# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456
28+
# np.int64(ts_ns // precision_factor) # is INCORRECT 1357081855123457
29+
# np.int64(ts_ns // np.int64(precision_factor) # is CORRECT 1357081855123456
2830

29-
_time_precision_factors = {
30-
"n": 1,
31-
"u": np.int64(1e3),
32-
"ms": np.int64(1e6),
33-
"s": np.int64(1e9),
34-
"m": np.int64(1e9 * 60),
35-
"h": np.int64( 1e9 * 3600),
36-
}
31+
_time_precision_factors = {"n": 1,
32+
"u": np.int64(1e3),
33+
"ms": np.int64(1e6),
34+
"s": np.int64(1e9),
35+
"m": np.int64(1e9 * 60),
36+
"h": np.int64(1e9 * 3600), }
3737

3838

3939
def _convert_timestamp(timestamp, time_precision=None):
@@ -56,7 +56,7 @@ def _convert_timestamp(timestamp, time_precision=None):
5656
timestamp = timestamp.astimezone('UTC')
5757

5858
nanoseconds = (timestamp - EPOCH).value
59-
precision_factor =_time_precision_factors.get(time_precision, 1)
59+
precision_factor = _time_precision_factors.get(time_precision, 1)
6060
return np.int64(nanoseconds // np.int64(precision_factor))
6161
raise ValueError(timestamp)
6262

influxdb/tests/dataframe_client_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,16 +930,22 @@ def test_get_list_database(self):
930930

931931
def test_datetime_to_epoch(self):
932932
"""Test convert datetime to epoch in TestDataFrameClient object.
933-
Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation
934-
Choosing the test value is important that nanosecond resolution values are greater than 895ns
933+
934+
Precisions factors must be int for correct calculation to ints.
935+
if precision is float the result of a floor calc is an approximation
936+
Choosing the test value is important that nanosecond resolution
937+
values are greater than 895ns
938+
935939
Example : the issue is only observable ns > 895ns
936940
# ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00')
937941
# ts_ns = np.int64(ts.value)
938942
# # For conversion to microsecond
939943
# precision_factor=1e3
940944
# expected_ts_us = 1357081855123456
941-
# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457
942-
# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456
945+
# following is INCORRECT 1357081855123457
946+
# np.int64(ts_ns // precision_factor)
947+
# following is CORRECT 1357081855123456
948+
# np.int64(ts_ns // np.int64(precision_factor)
943949
944950
"""
945951
timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00')

influxdb/tests/test_line_protocol.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,30 @@ def test_make_lines(self):
4949

5050
def test_convert_timestamp(self):
5151
"""Test line_protocol _convert_timestamp
52-
Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation
53-
Choosing the test value is important that nanosecond resolution values are greater than 895ns
52+
53+
Precisions factors must be int for correct calculation to ints. if
54+
precision is float the result of a floor calc is an approximation
55+
Choosing the test value is important that nanosecond resolution values
56+
are greater than 895ns
57+
5458
Example : the issue is only observable ns > 895ns
5559
# ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00')
5660
# ts_ns = np.int64(ts.value)
5761
# # For conversion to microsecond
5862
# precision_factor=1e3
5963
# expected_ts_us = 1357081855123456
60-
# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457
61-
# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456
64+
# # following is INCORRECT 1357081855123457
65+
# np.int64(ts_ns // precision_factor)
66+
# # following is CORRECT 1357081855123456
67+
# np.int64(ts_ns // np.int64(precision_factor)
6268
6369
"""
6470

65-
#TODO: add test for timestamp isinstance(timestamp, Integral)
66-
#TODO: add test for timestamp isinstance(_get_unicode(timestamp), text_type)
67-
#TODO: add test for timestamp isinstance(timestamp, datetime) also include test tzinfo present or not
68-
69-
71+
# TODO: add tests for timestamp instances
72+
# 1) isinstance(timestamp, Integral)
73+
# 2) isinstance(_get_unicode(timestamp), text_type)
74+
# 3) isinstance(timestamp, datetime) with tzinfo
75+
# 4) isinstance(timestamp, datetime) without tzinfo
7076

7177
timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00')
7278
self.assertEqual(

0 commit comments

Comments
 (0)