Skip to content

Commit

Permalink
Added dimension_range utility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 5, 2018
1 parent 6486f12 commit 1cfe7e4
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/core/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from holoviews.core.util import (
sanitize_identifier_fn, find_range, max_range, wrap_tuple_streams,
deephash, merge_dimensions, get_path, make_path_unique, compute_density,
date_range, dt_to_int, compute_edges, isfinite, cross_index, closest_match
date_range, dt_to_int, compute_edges, isfinite, cross_index, closest_match,
dimension_range
)
from holoviews import Dimension, Element
from holoviews.streams import PointerXY
Expand Down Expand Up @@ -405,6 +406,28 @@ def test_soft_range(self):
self.assertEqual(find_range(self.float_vals, soft_range=(np.NaN, 100)), (-0.1424, 100))


class TestDimensionRange(unittest.TestCase):
"""
Tests for dimension_range function.
"""

def setUp(self):
self.date_range = (np.datetime64(datetime.datetime(2017, 1, 1)),
np.datetime64(datetime.datetime(2017, 1, 2)))
self.date_range2 = (np.datetime64(datetime.datetime(2016, 12, 31)),
np.datetime64(datetime.datetime(2017, 1, 3)))

def test_dimension_range_date_hard_range(self):
drange = dimension_range(self.date_range2[0], self.date_range2[1],
self.date_range, (None, None))
self.assertEqual(drange, self.date_range)

def test_dimension_range_date_soft_range(self):
drange = dimension_range(self.date_range[0], self.date_range[1],
(None, None), self.date_range2)
self.assertEqual(drange, self.date_range2)


class TestMaxRange(unittest.TestCase):
"""
Tests for max_range function.
Expand Down

0 comments on commit 1cfe7e4

Please sign in to comment.