Did I find the right examples for you? yes no

All Samples(14)  |  Call(14)  |  Derive(0)  |  Import(0)
Apply linear map to input points.

The linear map ``offset + scale*x`` that maps the domain `old` to
the domain `new` is applied to the points `x`.

Parameters
----------
x : array_like
    Points to be mapped. If `x` is a subtype of ndarray the subtype
    will be preserved.(more...)

        def mapdomain(x, old, new) :
    """
    Apply linear map to input points.

    The linear map ``offset + scale*x`` that maps the domain `old` to
    the domain `new` is applied to the points `x`.

    Parameters
    ----------
    x : array_like
        Points to be mapped. If `x` is a subtype of ndarray the subtype
        will be preserved.
    old, new : array_like
        The two domains that determine the map.  Each must (successfully)
        convert to 1-d arrays containing precisely two values.

    Returns
    -------
    x_out : ndarray
        Array of points of the same shape as `x`, after application of the
        linear map between the two domains.

    See Also
    --------
    getdomain, mapparms

    Notes
    -----
    Effectively, this implements:

    .. math ::
        x\\_out = new[0] + m(x - old[0])

    where

    .. math ::
        m = \\frac{new[1]-new[0]}{old[1]-old[0]}

    Examples
    --------
    >>> from numpy import polynomial as P
    >>> old_domain = (-1,1)
    >>> new_domain = (0,2*np.pi)
    >>> x = np.linspace(-1,1,6); x
    array([-1. , -0.6, -0.2,  0.2,  0.6,  1. ])
    >>> x_out = P.mapdomain(x, old_domain, new_domain); x_out
    array([ 0.        ,  1.25663706,  2.51327412,  3.76991118,  5.02654825,
            6.28318531])
    >>> x - P.mapdomain(x_out, new_domain, old_domain)
    array([ 0.,  0.,  0.,  0.,  0.,  0.])

    Also works for complex numbers (and thus can be used to map any line in
    the complex plane to any other line therein).

    >>> i = complex(0,1)
    >>> old = (-1 - i, 1 + i)
    >>> new = (-1 + i, 1 - i)
    >>> z = np.linspace(old[0], old[1], 6); z
    array([-1.0-1.j , -0.6-0.6j, -0.2-0.2j,  0.2+0.2j,  0.6+0.6j,  1.0+1.j ])
    >>> new_z = P.mapdomain(z, old, new); new_z
    array([-1.0+1.j , -0.6+0.6j, -0.2+0.2j,  0.2-0.2j,  0.6-0.6j,  1.0-1.j ])

    """
    x = np.asanyarray(x)
    off, scl = mapparms(old, new)
    return off + scl*x
        


src/n/u/nupic-linux64-HEAD/lib64/python2.6/site-packages/numpy/polynomial/tests/test_polyutils.py   nupic-linux64(Download)
        dom2 = [1,3]
        tgt = dom2
        res = pu. mapdomain(dom1, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = dom2
        x = dom1
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = np.array([dom2, dom2])
        x = np.array([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        # test that subtypes are preserved.
        dom1 = [0,4]
        dom2 = [1,3]
        x = np.matrix([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)

src/s/p/Spherebot-Host-GUI-HEAD/InkscapePortable/App/Inkscape/python/Lib/site-packages/numpy/polynomial/tests/test_polyutils.py   Spherebot-Host-GUI(Download)
        dom2 = [1,3]
        tgt = dom2
        res = pu. mapdomain(dom1, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        # test for complex values
        dom1 = [0 - 1j, 2 + 1j]
        dom2 = [-2, 2]
        tgt = dom2
        res = pu.mapdomain(dom1, dom1, dom2)

src/m/i/MissionPlanner-HEAD/Lib/site-packages/numpy/polynomial/tests/test_polyutils.py   MissionPlanner(Download)
        dom2 = [1,3]
        tgt = dom2
        res = pu. mapdomain(dom1, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = dom2
        x = dom1
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = np.array([dom2, dom2])
        x = np.array([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        # test that subtypes are preserved.
        dom1 = [0,4]
        dom2 = [1,3]
        x = np.matrix([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)

src/n/u/numpy-1.8.1/numpy/polynomial/tests/test_polyutils.py   numpy(Download)
        dom2 = [1, 3]
        tgt = dom2
        res = pu. mapdomain(dom1, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = dom2
        x = dom1
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        tgt = np.array([dom2, dom2])
        x = np.array([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)
        assert_almost_equal(res, tgt)
 
        # test that subtypes are preserved.
        dom1 = [0, 4]
        dom2 = [1, 3]
        x = np.matrix([dom1, dom1])
        res = pu.mapdomain(x, dom1, dom2)