Did I find the right examples for you? yes no

numpy.polynomial.polyutils.getdomain

All Samples(8)  |  Call(8)  |  Derive(0)  |  Import(0)
```Return a domain suitable for given abscissae.

Find a domain suitable for a polynomial or Chebyshev series
defined at the values supplied.

Parameters
----------
x : array_like
1-d array of abscissae whose domain will be determined.
(more...)
```

```        def getdomain(x) :
"""
Return a domain suitable for given abscissae.

Find a domain suitable for a polynomial or Chebyshev series
defined at the values supplied.

Parameters
----------
x : array_like
1-d array of abscissae whose domain will be determined.

Returns
-------
domain : ndarray
1-d array containing two values.  If the inputs are complex, then
the two returned points are the lower left and upper right corners
of the smallest rectangle (aligned with the axes) in the complex
plane containing the points `x`. If the inputs are real, then the
two points are the ends of the smallest interval containing the
points `x`.

--------
mapparms, mapdomain

Examples
--------
>>> from numpy.polynomial import polyutils as pu
>>> points = np.arange(4)**2 - 5; points
array([-5, -4, -1,  4])
>>> pu.getdomain(points)
array([-5.,  4.])
>>> c = np.exp(complex(0,1)*np.pi*np.arange(12)/6) # unit circle
>>> pu.getdomain(c)
array([-1.-1.j,  1.+1.j])

"""
[x] = as_series([x], trim=False)
if x.dtype.char in np.typecodes['Complex'] :
rmin, rmax = x.real.min(), x.real.max()
imin, imax = x.imag.min(), x.imag.max()
return np.array((complex(rmin, imin), complex(rmax, imax)))
else :
return np.array((x.min(), x.max()))
```

```    def test_getdomain(self) :
# test for real values
x = [1, 10, 3, -1]
tgt = [-1,10]
res = pu.getdomain(x)
```
```        x = [1 + 1j, 1 - 1j, 0, 2]
tgt = [-1j, 2 + 1j]
res = pu.getdomain(x)
assert_almost_equal(res, tgt)

```

```    def test_getdomain(self) :
# test for real values
x = [1, 10, 3, -1]
tgt = [-1,10]
res = pu.getdomain(x)
```
```        x = [1 + 1j, 1 - 1j, 0, 2]
tgt = [-1j, 2 + 1j]
res = pu.getdomain(x)
assert_almost_equal(res, tgt)

```

```    def test_getdomain(self) :
# test for real values
x = [1, 10, 3, -1]
tgt = [-1,10]
res = pu.getdomain(x)
```
```        x = [1 + 1j, 1 - 1j, 0, 2]
tgt = [-1j, 2 + 1j]
res = pu.getdomain(x)
assert_almost_equal(res, tgt)

```

```    def test_getdomain(self) :
# test for real values
x = [1, 10, 3, -1]
tgt = [-1, 10]
res = pu.getdomain(x)
```
```        x = [1 + 1j, 1 - 1j, 0, 2]
tgt = [-1j, 2 + 1j]
res = pu.getdomain(x)
assert_almost_equal(res, tgt)

```