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

Commit 7e161e2

Browse files
committed
[FIX] CI further Flake8 fixes
1 parent bf88766 commit 7e161e2

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

influxdb/_dataframe_client.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@
1515
from .client import InfluxDBClient
1616
from .line_protocol import _escape_tag
1717

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

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

3739

3840
def _pandas_time_unit(time_precision):
@@ -280,7 +282,7 @@ def _convert_dataframe_to_json(dataframe,
280282
# Convert dtype for json serialization
281283
dataframe = dataframe.astype('object')
282284

283-
precision_factor =_time_precision_factors.get(time_precision, 1)
285+
precision_factor = _time_precision_factors.get(time_precision, 1)
284286

285287
points = [
286288
{'measurement': measurement,
@@ -343,11 +345,11 @@ def _convert_dataframe_to_lines(self,
343345
field_columns = list(column_series[~column_series.isin(
344346
tag_columns)])
345347

346-
precision_factor =_time_precision_factors.get(time_precision, 1)
348+
precision_factor = _time_precision_factors.get(time_precision, 1)
347349

348350
# Make array of timestamp ints
349351
if isinstance(dataframe.index, pd.PeriodIndex):
350-
time = ((dataframe.index.to_timestamp().values.astype(np.int64) //
352+
time = ((dataframe.index.to_timestamp().values.astype(np.int64) //
351353
precision_factor).astype(np.int64).astype(str))
352354
else:
353355
time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) //
@@ -458,5 +460,5 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'):
458460

459461
def _datetime_to_epoch(self, datetime, time_precision='s'):
460462
nanoseconds = (datetime - self.EPOCH).value
461-
precision_factor =_time_precision_factors.get(time_precision, 1)
463+
precision_factor = _time_precision_factors.get(time_precision, 1)
462464
return np.int64(nanoseconds // np.int64(precision_factor))

0 commit comments

Comments
 (0)