Skip to content

Commit

Permalink
Merge pull request #1082 from ioam/hline_fix
Browse files Browse the repository at this point in the history
Fixed HLine dimension_values
  • Loading branch information
jlstevens committed Jan 26, 2017
2 parents aeb487b + c2af94a commit 13702cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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))

0 comments on commit 13702cc

Please sign in to comment.