Skip to content

Commit 2f74b4b

Browse files
committed
resources: Add additional column reserve keyword.
1 parent 3593618 commit 2f74b4b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

iobeam/resources/data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def toDict(self):
137137
class DataStore(object):
138138
"""A collection of data streams with rows batched by time."""
139139

140+
_RESERVED_NAMES = ["time", "time_offset", "all"]
141+
140142
def __init__(self, columns):
141143
"""Construct a new DataStore object with given columns.
142144
@@ -151,10 +153,9 @@ def __init__(self, columns):
151153
raise ValueError("columns cannot be None or empty")
152154
if not isinstance(columns, list):
153155
raise ValueError("columns must be a list of strings")
154-
if "time" in columns:
155-
raise ValueError("'time' is a reserved column name")
156-
if "time_offset" in columns:
157-
raise ValueError("'time_offset' is a reserved column name")
156+
for name in DataStore._RESERVED_NAMES:
157+
if name in columns:
158+
raise ValueError("'{}' is a reserved column name".format(name))
158159

159160
self._columns = list(columns) # defensive copy
160161
self._rows = []

tests/resources/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def verify(fields):
146146
except ValueError:
147147
pass
148148

149-
cases = [None, [], ["time", "col"], ["time_offset", "col"]]
149+
cases = [None, [], ["time", "col"], ["time_offset", "col"], ["all"]]
150150
for c in cases:
151151
verify(c)
152152

0 commit comments

Comments
 (0)