Ejemplo n.º 1
0
    import pandas as pd
except:
    pd = None

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)
from holoviews import Dimension, Element
from holoviews.streams import PointerXY
from holoviews.element.comparison import ComparisonTestCase

py_version = sys.version_info.major

sanitize_identifier = sanitize_identifier_fn.instance()


class TestDeepHash(ComparisonTestCase):
    """
    Tests of deephash function used for memoization.
    """
    def test_deephash_list_equality(self):
        self.assertEqual(deephash([1, 2, 3]), deephash([1, 2, 3]))

    def test_deephash_list_inequality(self):
        obj1 = [1, 2, 3]
        obj2 = [1, 2, 3, 4]
        self.assertNotEqual(deephash(obj1), deephash(obj2))

    def test_deephash_set_equality(self):
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
Unit tests of the helper functions in core.utils
"""
import sys, math
import unittest
from unittest import SkipTest

import numpy as np

from holoviews.core.util import sanitize_identifier_fn, find_range, max_range
from holoviews.element.comparison import ComparisonTestCase

py_version = sys.version_info.major

sanitize_identifier = sanitize_identifier_fn.instance()


class TestAllowablePrefix(ComparisonTestCase):
    """
    Tests of allowable and hasprefix method.
    """

    def test_allowable_false_1(self):
        self.assertEqual(sanitize_identifier.allowable("trait_names"), False)

    def test_allowable_false_2(self):
        self.assertEqual(sanitize_identifier.allowable("_repr_png_"), False)

    def test_allowable_false_3(self):
        self.assertEqual(sanitize_identifier.allowable("_ipython_display_"), False)