From 1cfe7e4d125fa66d2428fdf66ad5d662cc20fa82 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Thu, 4 Oct 2018 12:49:52 +0100
Subject: [PATCH] Added dimension_range utility tests
---
tests/core/testutils.py | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/tests/core/testutils.py b/tests/core/testutils.py
index c854a26504..bd37d5d93f 100644
--- a/tests/core/testutils.py
+++ b/tests/core/testutils.py
@@ -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
@@ -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.