Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed Stream.value to 'contents' to avoid name clashes #845

Merged
merged 2 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def _execute_callback(self, *args):
retval = next(self.callback)
else:
# Additional validation needed to ensure kwargs don't clash
kwarg_items = [s.value.items() for s in self.streams]
kwarg_items = [s.contents.items() for s in self.streams]
flattened = [el for kws in kwarg_items for el in kws]
klist = [k for k,_ in flattened]
clashes = set([k for k in klist if klist.count(k) > 1])
Expand Down
10 changes: 5 additions & 5 deletions holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Preprocessor(param.Parameterized):
and returns a dictionary. Where possible, Preprocessors should have
valid reprs that can be evaluated.

Preprocessors are used to set the value of a stream based on the
Preprocessors are used to set the contents of a stream based on the
parameter values. They may be used for debugging purposes or to
remap or repack parameter values before they are passed onto to the
subscribers.
Expand Down Expand Up @@ -87,8 +87,8 @@ def trigger(cls, streams):
subscriber may be set multiple times across streams but only
needs to be called once.
"""
# Union of stream values
items = [stream.value.items() for stream in streams]
# Union of stream contents
items = [stream.contents.items() for stream in streams]
union = [kv for kvs in items for kv in kvs]
klist = [k for k,_ in union]
clashes = set([k for k in klist if klist.count(k) > 1])
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(self, preprocessors=[], source=None, subscribers=[], **params):


@property
def value(self):
def contents(self):
remapped = {k:v for k,v in self.get_param_values() if k!= 'name' }
for preprocessor in self.preprocessors:
remapped = preprocessor(remapped)
Expand Down Expand Up @@ -243,7 +243,7 @@ def __init__(self, obj, **params):


@property
def value(self):
def contents(self):
if isinstance(self._obj, type):
remapped={k: getattr(self._obj,k)
for k in self._obj.params().keys() if k!= 'name'}
Expand Down
26 changes: 13 additions & 13 deletions tests/teststreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class TestPositionStreams(ComparisonTestCase):
def test_positionX_init(self):
PositionX()

def test_positionXY_init_values(self):
def test_positionXY_init_contents(self):
position = PositionXY(x=1, y=3)
self.assertEqual(position.value, dict(x=1, y=3))
self.assertEqual(position.contents, dict(x=1, y=3))

def test_positionXY_update_values(self):
def test_positionXY_update_contents(self):
position = PositionXY()
position.update(x=5, y=10)
self.assertEqual(position.value, dict(x=5, y=10))
self.assertEqual(position.contents, dict(x=5, y=10))

def test_positionY_const_parameter(self):
position = PositionY()
Expand All @@ -56,27 +56,27 @@ def tearDown(self):
self.inner.x = 0
self.inner.y = 0

def test_object_value(self):
def test_object_contents(self):
obj = self.inner()
stream = ParamValues(obj)
self.assertEqual(stream.value, {'x':0, 'y':0})
self.assertEqual(stream.contents, {'x':0, 'y':0})

def test_class_value(self):
stream = ParamValues(self.inner)
self.assertEqual(stream.value, {'x':0, 'y':0})
self.assertEqual(stream.contents, {'x':0, 'y':0})

def test_object_value_update(self):
obj = self.inner()
stream = ParamValues(obj)
self.assertEqual(stream.value, {'x':0, 'y':0})
self.assertEqual(stream.contents, {'x':0, 'y':0})
stream.update(x=5, y=10)
self.assertEqual(stream.value, {'x':5, 'y':10})
self.assertEqual(stream.contents, {'x':5, 'y':10})

def test_class_value_update(self):
stream = ParamValues(self.inner)
self.assertEqual(stream.value, {'x':0, 'y':0})
self.assertEqual(stream.contents, {'x':0, 'y':0})
stream.update(x=5, y=10)
self.assertEqual(stream.value, {'x':5, 'y':10})
self.assertEqual(stream.contents, {'x':5, 'y':10})



Expand Down Expand Up @@ -142,8 +142,8 @@ class TestPreprocessors(ComparisonTestCase):

def test_rename_preprocessor(self):
position = PositionXY([Rename(x='x1',y='y1')], x=1, y=3)
self.assertEqual(position.value, dict(x1=1, y1=3))
self.assertEqual(position.contents, dict(x1=1, y1=3))

def test_group_preprocessor(self):
position = PositionXY([Group('mygroup')], x=1, y=3)
self.assertEqual(position.value, dict(mygroup={'x':1,'y':3}))
self.assertEqual(position.contents, dict(mygroup={'x':1,'y':3}))