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

Fixed HLine dimension_values #1082

Merged
merged 1 commit into from
Jan 26, 2017
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
9 changes: 9 additions & 0 deletions holoviews/element/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ class HLine(Annotation):
def __init__(self, y, **params):
super(HLine, self).__init__(y, **params)

def dimension_values(self, dimension):
index = self.get_dimension_index(dimension)
if index == 0:
return []
elif index == 1:
return [self.data]
else:
return super(HLine, self).dimension_values(dimension)



class Spline(Annotation):
Expand Down
20 changes: 20 additions & 0 deletions tests/testannotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np

from holoviews import Image, HLine, VLine
from holoviews.element.comparison import ComparisonTestCase

class AnnotationTests(ComparisonTestCase):
"""
Tests allowable data formats when constructing
the basic Element types.
"""

def test_hline_dimension_values(self):
hline = HLine(0)
self.assertEqual(hline.range(0), (None, None))
self.assertEqual(hline.range(1), (0, 0))

def test_vline_dimension_values(self):
hline = VLine(0)
self.assertEqual(hline.range(0), (0, 0))
self.assertEqual(hline.range(1), (None, None))