mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-15 12:15:22 +08:00
BUG: Make all iteration related methods fo BarData match __iter__
`for s in data` and methods like `for s in data.keys` were not producing the same list of active sids Make the other iteration methods match __iter__ by using the contains method to check whether or not the sid is active. For use of data outside of the algoscript context, which needs access to all data fields use data._data
This commit is contained in:
+19
-10
@@ -164,23 +164,32 @@ class BarData(object):
|
||||
|
||||
def __iter__(self):
|
||||
for sid, data in self._data.iteritems():
|
||||
if len(data):
|
||||
yield sid
|
||||
|
||||
def keys(self):
|
||||
return self._data.keys()
|
||||
# Allow contains override to filter out sids.
|
||||
if sid in self:
|
||||
if len(data):
|
||||
yield sid
|
||||
|
||||
def iterkeys(self):
|
||||
return self._data.iterkeys()
|
||||
# Allow contains override to filter out sids.
|
||||
return [sid for sid in self._data.iterkeys() if sid in self]
|
||||
|
||||
def keys(self):
|
||||
# Allow contains override to filter out sids.
|
||||
return list(self.iterkeys())
|
||||
|
||||
def itervalues(self):
|
||||
return self._data.itervalues()
|
||||
return (value for sid, value in self.iteritems())
|
||||
|
||||
def values(self):
|
||||
return list(self.itervalues())
|
||||
|
||||
def iteritems(self):
|
||||
return self._data.iteritems()
|
||||
return ((sid, value) for sid, value
|
||||
in self._data.iteritems()
|
||||
if sid in self)
|
||||
|
||||
def items(self):
|
||||
return self._data.items()
|
||||
return list(self.iteritems())
|
||||
|
||||
def __len__(self):
|
||||
return len(self._data.keys())
|
||||
return len(self.keys())
|
||||
|
||||
Reference in New Issue
Block a user