def test_interval_with_range(self, t, x): values = (1, 3) s = Temporal((1, 3))._setup(t, IntervalProperty()) normed = (x - x.min()) / (x.max() - x.min()) expected = normed * (values[1] - values[0]) + values[0] assert_array_equal(s(t), expected)
def test_interval_with_norm(self, t, x): norm = t[1], t[2] s = Temporal(norm=norm)._setup(t, IntervalProperty()) n = mpl.dates.date2num(norm) normed = (x - n[0]) / (n[1] - n[0]) assert_array_equal(s(t), normed)
def test_interval_with_range_norm_and_transform(self, x): x = pd.Series([1, 10, 100]) # TODO param order? s = Continuous((2, 3), (10, 100), "log")._setup(x, IntervalProperty()) assert_array_equal(s(x), [1, 2, 3])
def test_interval_with_norm(self, x): s = Continuous(norm=(3, 7))._setup(x, IntervalProperty()) assert_array_equal(s(x), [-.5, 0, 1.5])
def test_interval_with_range(self, x): s = Continuous((1, 3))._setup(x, IntervalProperty()) assert_array_equal(s(x), [1, 1.5, 3])
def test_interval_defaults(self, x): s = Continuous()._setup(x, IntervalProperty()) assert_array_equal(s(x), [0, .25, 1])
def test_interval_defaults(self, t, x): s = Temporal()._setup(t, IntervalProperty()) normed = (x - x.min()) / (x.max() - x.min()) assert_array_equal(s(t), normed)
def test_interval_dict(self, x): vs = {"a": 3, "b": 4, "c": 6} s = Nominal(vs)._setup(x, IntervalProperty()) assert_array_equal(s(x), [3, 6, 4, 6])
def test_interval_list(self, x): vs = [2, 5, 4] s = Nominal(vs)._setup(x, IntervalProperty()) assert_array_equal(s(x), [2, 5, 4, 5])
def test_interval_tuple_numeric(self, y): s = Nominal((1, 2))._setup(y, IntervalProperty()) assert_array_equal(s(y), [1.5, 2, 1, 2])
def test_interval_tuple(self, x): s = Nominal((1, 2))._setup(x, IntervalProperty()) assert_array_equal(s(x), [2, 1.5, 1, 1.5])