Here are the examples of the python api numpy.double taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_ndgriddata.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_complex_2d(self):
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
y = y - 2j*y[::-1]
xi = x[:,None,:] + np.array([0,0,0])[None,:,None]
for method in ('nearest', 'linear', 'cubic'):
for rescale in (True, False):
msg = repr((method, rescale))
yi = griddata(x, y, xi, method=method, rescale=rescale)
astert_equal(yi.shape, (5, 3), err_msg=msg)
astert_allclose(yi, np.tile(y[:,None], (1, 3)),
atol=1e-14, err_msg=msg)
3
View Complete Implementation : test_interpnd.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_tri_input(self):
# Test at single points
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
y = y - 3j*y
tri = qhull.Delaunay(x)
yi = interpnd.LinearNDInterpolator(tri, y)(x)
astert_almost_equal(y, yi)
3
View Complete Implementation : test_interpnd.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_tri_input(self):
# Test at single points
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
y = y - 3j*y
tri = qhull.Delaunay(x)
yi = interpnd.CloughTocher2DInterpolator(tri, y)(x)
astert_almost_equal(y, yi)
3
View Complete Implementation : test_interpnd.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_tripoints_input_rescale(self):
# Test at single points
x = np.array([(0,0), (-5,-5), (-5,5), (5, 5), (2.5, 3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
y = y - 3j*y
tri = qhull.Delaunay(x)
yi = interpnd.LinearNDInterpolator(tri.points, y)(x)
yi_rescale = interpnd.LinearNDInterpolator(tri.points, y,
rescale=True)(x)
astert_almost_equal(yi, yi_rescale)
3
View Complete Implementation : test_interpnd.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_tri_input_rescale(self):
# Test at single points
x = np.array([(0,0), (-5,-5), (-5,5), (5, 5), (2.5, 3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
y = y - 3j*y
tri = qhull.Delaunay(x)
match = ("Rescaling is not supported when pasting a "
"Delaunay triangulation as ``points``.")
with pytest.raises(ValueError, match=match):
interpnd.LinearNDInterpolator(tri, y, rescale=True)(x)
3
View Complete Implementation : test_ndgriddata.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_alternative_call(self):
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = (np.arange(x.shape[0], dtype=np.double)[:,None]
+ np.array([0,1])[None,:])
for method in ('nearest', 'linear', 'cubic'):
for rescale in (True, False):
msg = repr((method, rescale))
yi = griddata((x[:,0], x[:,1]), y, (x[:,0], x[:,1]), method=method,
rescale=rescale)
astert_allclose(y, yi, atol=1e-14, err_msg=msg)
3
View Complete Implementation : test_ndgriddata.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_multipoint_2d(self):
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = np.arange(x.shape[0], dtype=np.double)
xi = x[:,None,:] + np.array([0,0,0])[None,:,None]
for method in ('nearest', 'linear', 'cubic'):
for rescale in (True, False):
msg = repr((method, rescale))
yi = griddata(x, y, xi, method=method, rescale=rescale)
astert_equal(yi.shape, (5, 3), err_msg=msg)
astert_allclose(yi, np.tile(y[:,None], (1, 3)),
atol=1e-14, err_msg=msg)
3
View Complete Implementation : gen_fftw_ref.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def gen_data(dt):
arrays = {}
if dt == np.double:
pg = './fftw_double'
elif dt == np.float32:
pg = './fftw_single'
else:
raise ValueError("unknown: %s" % dt)
# Generate test data using FFTW for reference
for type in [1, 2, 3, 4, 5, 6, 7, 8]:
arrays[type] = {}
for sz in SZ:
a = Popen([pg, str(type), str(sz)], stdout=PIPE, stderr=STDOUT)
st = [i.strip() for i in a.stdout.readlines()]
arrays[type][sz] = np.fromstring(",".join(st), sep=',', dtype=dt)
return arrays
3
View Complete Implementation : test_ndgriddata.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_multivalue_2d(self):
x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)],
dtype=np.double)
y = (np.arange(x.shape[0], dtype=np.double)[:,None]
+ np.array([0,1])[None,:])
for method in ('nearest', 'linear', 'cubic'):
for rescale in (True, False):
msg = repr((method, rescale))
yi = griddata(x, y, x, method=method, rescale=rescale)
astert_allclose(y, yi, atol=1e-14, err_msg=msg)
3
View Complete Implementation : test_interpnd.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def test_square_rescale(self):
# Test barycentric interpolation on a rectangle with rescaling
# agaings the same implementation without rescaling
points = np.array([(0,0), (0,100), (10,100), (10,0)], dtype=np.double)
values = np.array([1., 2., -3., 5.], dtype=np.double)
xx, yy = np.broadcast_arrays(np.linspace(0, 10, 14)[:,None],
np.linspace(0, 100, 14)[None,:])
xx = xx.ravel()
yy = yy.ravel()
xi = np.array([xx, yy]).T.copy()
zi = interpnd.LinearNDInterpolator(points, values)(xi)
zi_rescaled = interpnd.LinearNDInterpolator(points, values,
rescale=True)(xi)
astert_almost_equal(zi, zi_rescaled)