Ejemplo n.º 1
0
 def __init__(self,
              x='identity',
              y='identity',
              xlim=None,
              ylim=None,
              expand=True):
     self.trans = NS(x=gettrans(x), y=gettrans(y))
     self.limits = NS(x=xlim, y=ylim)
     self.expand = expand
Ejemplo n.º 2
0
def test_gettrans():
    t0 = identity_trans()
    t1 = gettrans(t0)
    t2 = gettrans(identity_trans)
    t3 = gettrans('identity')
    assert all(isinstance(x, identity_trans) for x in (t0, t1, t2, t3))

    t = gettrans(exp_trans)
    assert t.__class__.__name__ == 'power_e_trans'

    with pytest.raises(ValueError):
        gettrans(object)
Ejemplo n.º 3
0
def _test_trans(trans, x):
    t = gettrans(trans())
    xt = t.transform(x)
    x2 = t.inverse(xt)
    # round trip
    npt.assert_allclose(x, x2)
    major = t.breaks([min(x), max(x)])
    minor = t.minor_breaks(t.transform(major))
    # Breaks and they are finite
    assert len(major)
    assert len(minor)
    assert all(np.isfinite(major))
    assert all(np.isfinite(minor))
    # Not breaks outside the domain
    assert all(major >= t.domain[0])
    assert all(major <= t.domain[1])
    assert all(minor >= t.domain[0])
    assert all(minor <= t.domain[1])
Ejemplo n.º 4
0
def test_gettrans():
    t0 = identity_trans()
    t1 = gettrans(t0)
    t2 = gettrans(identity_trans)
    t3 = gettrans('identity')
    assert all(
        isinstance(x, identity_trans) for x in (t0, t1, t2, t3))

    t = gettrans(exp_trans)
    assert t.__class__.__name__ == 'power_e_trans'

    with pytest.raises(ValueError):
        gettrans(object)
def _test_trans(trans, x):
    t = gettrans(trans())
    xt = t.transform(x)
    x2 = t.inverse(xt)
    is_log_trans = ('log' in t.__class__.__name__ and hasattr(t, 'base'))
    # round trip
    npt.assert_allclose(x, x2)
    major = t.breaks([min(x), max(x)])
    minor = t.minor_breaks(t.transform(major))
    # Breaks and they are finite
    assert len(major)
    if is_log_trans and int(t.base) == 2:
        # Minor breaks for base == 2
        assert len(minor) == 0
    else:
        assert len(minor)
    assert all(np.isfinite(major))
    assert all(np.isfinite(minor))
    # Not breaks outside the domain
    assert all(major >= t.domain[0])
    assert all(major <= t.domain[1])
    assert all(minor >= t.domain[0])
    assert all(minor <= t.domain[1])
Ejemplo n.º 6
0
def _test_trans(trans, x):
    t = gettrans(trans())
    xt = t.transform(x)
    x2 = t.inverse(xt)
    is_log_trans = (t.__class__.__name__.startswith('log') and
                    hasattr(t, 'base'))
    # round trip
    npt.assert_allclose(x, x2)
    major = t.breaks([min(x), max(x)])
    minor = t.minor_breaks(t.transform(major))
    # Breaks and they are finite
    assert len(major)
    if is_log_trans and int(t.base) == 2:
        # Minor breaks for base == 2
        assert len(minor) == 0
    else:
        assert len(minor)
    assert all(np.isfinite(major))
    assert all(np.isfinite(minor))
    # Not breaks outside the domain
    assert all(major >= t.domain[0])
    assert all(major <= t.domain[1])
    assert all(minor >= t.domain[0])
    assert all(minor <= t.domain[1])
Ejemplo n.º 7
0
 def trans(self, value):
     self._trans = gettrans(value)
     self._trans.aesthetic = self.aesthetics[0]
Ejemplo n.º 8
0
 def trans(self, value):
     t = gettrans(value)
     self._check_trans(t)
     self._trans = t
     self._trans.aesthetic = self.aesthetics[0]
Ejemplo n.º 9
0
 def __init__(self, x='identity', y='identity', xlim=None, ylim=None):
     self.trans = Bunch(x=gettrans(x), y=gettrans(y))
     self.limits = Bunch(xlim=xlim, ylim=ylim)
Ejemplo n.º 10
0
 def __init__(self, x='identity', y='identity', xlim=None, ylim=None):
     self.trans = types.SimpleNamespace(x=gettrans(x), y=gettrans(y))
     self.limits = types.SimpleNamespace(xlim=xlim, ylim=ylim)
Ejemplo n.º 11
0
 def __init__(self, x='identity', y='identity',
              xlim=None, ylim=None):
     self.trans = Bunch(x=gettrans(x), y=gettrans(y))
     self.limits = Bunch(xlim=xlim, ylim=ylim)