Skip to content

Commit

Permalink
Fix bug in ARFFWriter
Browse files Browse the repository at this point in the history
We do not need to add/remove `label_col` from the fieldnames if it's None to begin with.
  • Loading branch information
desilinguist committed Feb 5, 2019
1 parent d515782 commit faf511e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skll/data/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _write_header(self, feature_set, output_file, filter_features):
features to include in this file.
"""
fieldnames = self._get_fieldnames(filter_features)
if self.label_col in fieldnames:
if self.label_col and self.label_col in fieldnames:
fieldnames.remove(self.label_col)

# Add relation to header
Expand All @@ -480,7 +480,8 @@ def _write_header(self, feature_set, output_file, filter_features):
"{" + ','.join(map(str,
sorted(set(self.feat_set.labels)))) +
"}", file=output_file)
fieldnames.append(self.label_col)
if self.label_col:
fieldnames.append(self.label_col)

# Create CSV writer to handle missing values for lines in data section
# and to ignore the instance values for non-numeric attributes
Expand Down

0 comments on commit faf511e

Please sign in to comment.