• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(16539)  |  Call(15592)  |  Derive(0)  |  Import(947)
zeros(shape, dtype=float, order='C')

Return a new array of given shape and type, filled with zeros.

Parameters
----------
shape : int or sequence of ints
    Shape of the new array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
    The desired data-type for the array, e.g., `numpy.int8`.  Default is
    `numpy.float64`.
order : {'C', 'F'}, optional
    Whether to store multidimensional data in C- or Fortran-contiguous
    (row- or column-wise) order in memory.

Returns
-------
out : ndarray
    Array of zeros with the given shape, dtype, and order.

See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.

Examples
--------
>>> np.zeros(5)
array([ 0.,  0.,  0.,  0.,  0.])

>>> np.zeros((5,), dtype=numpy.int)
array([0, 0, 0, 0, 0])

>>> np.zeros((2, 1))
array([[ 0.],
       [ 0.]])

>>> s = (2,2)
>>> np.zeros(s)
array([[ 0.,  0.],
       [ 0.,  0.]])

>>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
      dtype=[('x', '<i4'), ('y', '<i4')])

src/y/t/yt-1.7/yt/extensions/volume_rendering/software_sampler.py   yt(Download)
    def _construct_vector_array(self):
        rx = self.resolution[0] * self.res_fac[0]
        ry = self.resolution[1] * self.res_fac[1]
        # We should move away from pre-generation of vectors like this and into
        # the usage of on-the-fly generation in the VolumeIntegrator module
        self.image = na.zeros((rx,ry,3), dtype='float64', order='C')
        # We might have a different width and back_center
        bl = self.source.box_lengths
        px = na.linspace(-bl[0]/2.0, bl[0]/2.0, rx)[:,None]
        py = na.linspace(-bl[1]/2.0, bl[1]/2.0, ry)[None,:]
        inv_mat = self.source._inv_mat
        bc = self.source.origin + 0.5*self.source.box_vectors[0] \
                                + 0.5*self.source.box_vectors[1]
        vectors = na.zeros((rx, ry, 3),

src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/demo_agg_filter.py   matplotlib(Download)
    def prepare_image(self, src_image, dpi, pad):
        ny, nx, depth = src_image.shape
        #tgt_image = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
        padded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
        padded_src[pad:-pad, pad:-pad,:] = src_image[:,:,:]
 
        return padded_src#, tgt_image

src/m/a/matplotlib-HEAD/examples/pylab_examples/demo_agg_filter.py   matplotlib(Download)
    def prepare_image(self, src_image, dpi, pad):
        ny, nx, depth = src_image.shape
        #tgt_image = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
        padded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
        padded_src[pad:-pad, pad:-pad,:] = src_image[:,:,:]
 
        return padded_src#, tgt_image

src/a/l/algopy-HEAD/documentation/AD_tutorial_TU_Berlin/example7_simple_computation_of_the_hessian.py   algopy(Download)
at x = (3,7)
"""
 
import numpy; from numpy import sin,cos, array, zeros
from taylorpoly import UTPS
def f_fcn(x):
    return sin(x[0] + cos(x[1])*x[0])
 
S = array([[1,0,1],[0,1,1]], dtype=float)
P = S.shape[1]
print 'seed matrix with P = %d directions S = \n'%P, S
x1 = UTPS(zeros(1+2*P), P = P)
x2 = UTPS(zeros(1+2*P), P = P)
x2.data[0] = 7; x2.data[1::2] = S[1,:]
y = f_fcn([x1,x2])
print 'x1=',x1;  print 'x2=',x2; print 'y=',y
H = zeros((2,2),dtype=float)
H[0,0] = 2*y.coeff[0,2]
H[1,0] = H[0,1] = (y.coeff[2,2] - y.coeff[0,2] - y.coeff[1,2])
H[1,1] =  2*y.coeff[1,2]

src/b/r/brian-HEAD/trunk/dev/ideas/cuda/modelfitting/example.py   brian(Download)
# existence of the current spike 
spiketimes = numpy.hstack((-10000, spiketimes, -10000))
 
V = gpuarray.to_gpu(numpy.zeros(N, dtype=mydtype))
R = gpuarray.to_gpu(numpy.array(numpy.random.rand(N)*2e9+1e9, dtype=mydtype))
tau = gpuarray.to_gpu(numpy.array(numpy.random.rand(N)*0.050+0.001, dtype=mydtype))
I = gpuarray.to_gpu(numpy.array(I, dtype=mydtype))
num_coincidences = gpuarray.to_gpu(numpy.zeros(N, dtype=int))
spiketime_indices = gpuarray.to_gpu(numpy.zeros(N, dtype=int))
spiketimes = gpuarray.to_gpu(numpy.array(spiketimes, dtype=int))
spikecount = gpuarray.to_gpu(numpy.zeros(N, dtype=int))

src/b/r/brian-HEAD/dev/ideas/cuda/modelfitting/example.py   brian(Download)
# existence of the current spike 
spiketimes = numpy.hstack((-10000, spiketimes, -10000))
 
V = gpuarray.to_gpu(numpy.zeros(N, dtype=mydtype))
R = gpuarray.to_gpu(numpy.array(numpy.random.rand(N)*2e9+1e9, dtype=mydtype))
tau = gpuarray.to_gpu(numpy.array(numpy.random.rand(N)*0.050+0.001, dtype=mydtype))
I = gpuarray.to_gpu(numpy.array(I, dtype=mydtype))
num_coincidences = gpuarray.to_gpu(numpy.zeros(N, dtype=int))
spiketime_indices = gpuarray.to_gpu(numpy.zeros(N, dtype=int))
spiketimes = gpuarray.to_gpu(numpy.array(spiketimes, dtype=int))
spikecount = gpuarray.to_gpu(numpy.zeros(N, dtype=int))

src/a/l/algopy-HEAD/documentation/sphinx/examples/minimal_surface.py   algopy(Download)
# INITIAL VALUES
M = 30
h = 1./M
u = numpy.zeros((M,M),dtype=float)
u[0,:]=  [numpy.sin(numpy.pi*j*h/2.) for j in range(M)]
u[-1,:] = [ numpy.exp(numpy.pi/2) * numpy.sin(numpy.pi * j * h / 2.) for j in range(M)]
u[:,0]= 0
 
# BOX CONSTRAINTS
lo = 2.5
L = numpy.zeros((M,M),dtype=float)
 
for n in range(M):
    for m in range(M):

src/n/i/nipy-HEAD/nipy/algorithms/registration/resample.py   nipy(Download)
            output = cspline_resample3d(data, shape, t, dtype=dtype)
            output = output.astype(dtype)
        else: 
            output = np.zeros(shape, dtype=dtype)
            affine_transform(data, t[0:3,0:3], offset=t[0:3,3],
                             order=interp_order, cval=0, 
                             output_shape=shape, output=output)
        coords = np.rollaxis(t, 3, 0)
        if interp_order == 3: 
            cbspline = cspline_transform(data)
            output = np.zeros(shape, dtype='double')
            output = cspline_sample3d(output, cbspline, *coords)
            output = output.astype(dtype)
        else: 

src/m/a/matplotlib-HEAD/matplotlib/examples/event_handling/viewlims.py   matplotlib(Download)
    def __call__(self, xstart, xend, ystart, yend):
        self.x = np.linspace(xstart, xend, self.width)
        self.y = np.linspace(ystart, yend, self.height).reshape(-1,1)
        c = self.x + 1.0j * self.y
        threshold_time = np.zeros((self.height, self.width))
        z = np.zeros(threshold_time.shape, dtype=np.complex)
        mask = np.ones(threshold_time.shape, dtype=np.bool)

src/m/a/matplotlib-HEAD/examples/event_handling/viewlims.py   matplotlib(Download)
    def __call__(self, xstart, xend, ystart, yend):
        self.x = np.linspace(xstart, xend, self.width)
        self.y = np.linspace(ystart, yend, self.height).reshape(-1,1)
        c = self.x + 1.0j * self.y
        threshold_time = np.zeros((self.height, self.width))
        z = np.zeros(threshold_time.shape, dtype=np.complex)
        mask = np.ones(threshold_time.shape, dtype=np.bool)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next