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

fixes for mutable default parameters in DataFrame client #394

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions influxdb/_dataframe_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def write_points(self,
dataframe,
measurement,
tags=None,
tag_columns=[],
field_columns=[],
tag_columns=None,
field_columns=None,
time_precision=None,
database=None,
retention_policy=None,
Expand All @@ -72,6 +72,10 @@ def write_points(self,
figures for float and all significant figures for int datatypes.

"""
if tag_columns is None:
tag_columns = []
if field_columns is None:
field_columns = []
if batch_size:
number_batches = int(math.ceil(len(dataframe) / float(batch_size)))
for batch in range(number_batches):
Expand Down Expand Up @@ -166,8 +170,8 @@ def _convert_dataframe_to_json(self,
dataframe,
measurement,
tags=None,
tag_columns=[],
field_columns=[],
tag_columns=None,
field_columns=None,
time_precision=None):

if not isinstance(dataframe, pd.DataFrame):
Expand All @@ -179,9 +183,9 @@ def _convert_dataframe_to_json(self,
PeriodIndex.')

# Make sure tags and tag columns are correctly typed
tag_columns = tag_columns if tag_columns else []
field_columns = field_columns if field_columns else []
tags = tags if tags else {}
tag_columns = tag_columns if tag_columns is not None else []
field_columns = field_columns if field_columns is not None else []
tags = tags if tags is not None else {}
# Assume field columns are all columns not included in tag columns
if not field_columns:
field_columns = list(
Expand Down Expand Up @@ -221,8 +225,8 @@ def _convert_dataframe_to_json(self,
def _convert_dataframe_to_lines(self,
dataframe,
measurement,
field_columns=[],
tag_columns=[],
field_columns=None,
tag_columns=None,
global_tags={},
time_precision=None,
numeric_precision=None):
Expand All @@ -242,6 +246,8 @@ def _convert_dataframe_to_lines(self,
field_columns = []
if tag_columns is None:
tag_columns = []
if global_tags is None:
global_tags = {}

# Make sure field_columns and tag_columns are lists
field_columns = list(field_columns) if list(field_columns) else []
Expand Down