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

All Samples(33696)  |  Call(32082)  |  Derive(0)  |  Import(1614)
array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)

Create an array.

Parameters
----------
object : array_like
    An array, any object exposing the array interface, an
    object whose __array__ method returns an array, or any
    (nested) sequence.
dtype : data-type, optional
    The desired data-type for the array.  If not given, then
    the type will be determined as the minimum type required
    to hold the objects in the sequence.  This argument can only
    be used to 'upcast' the array.  For downcasting, use the
    .astype(t) method.
copy : bool, optional
    If true (default), then the object is copied.  Otherwise, a copy
    will only be made if __array__ returns a copy, if obj is a
    nested sequence, or if a copy is needed to satisfy any of the other
    requirements (`dtype`, `order`, etc.).
order : {'C', 'F', 'A'}, optional
    Specify the order of the array.  If order is 'C' (default), then the
    array will be in C-contiguous order (last-index varies the
    fastest).  If order is 'F', then the returned array
    will be in Fortran-contiguous order (first-index varies the
    fastest).  If order is 'A', then the returned array may
    be in any order (either C-, Fortran-contiguous, or even
    discontiguous).
subok : bool, optional
    If True, then sub-classes will be passed-through, otherwise
    the returned array will be forced to be a base-class array (default).
ndmin : int, optional
    Specifies the minimum number of dimensions that the resulting
    array should have.  Ones will be pre-pended to the shape as
    needed to meet this requirement.

Examples
--------
>>> np.array([1, 2, 3])
array([1, 2, 3])

Upcasting:

>>> np.array([1, 2, 3.0])
array([ 1.,  2.,  3.])

More than one dimension:

>>> np.array([[1, 2], [3, 4]])
array([[1, 2],
       [3, 4]])

Minimum dimensions 2:

>>> np.array([1, 2, 3], ndmin=2)
array([[1, 2, 3]])

Type provided:

>>> np.array([1, 2, 3], dtype=complex)
array([ 1.+0.j,  2.+0.j,  3.+0.j])

Data-type consisting of more than one element:

>>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
>>> x['a']
array([1, 3])

Creating an array from sub-classes:

>>> np.array(np.mat('1 2; 3 4'))
array([[1, 2],
       [3, 4]])

>>> np.array(np.mat('1 2; 3 4'), subok=True)
matrix([[1, 2],
        [3, 4]])

src/o/c/ocr-HEAD/pylenet/smala/examples/parity.py   ocr(Download)
def sample():
	X =  numpy.array(numpy.random.randint(2,size=[4]),dtype='f4', order='F')
	T =  numpy.array([numpy.sum(X)%2-0.5],            dtype='f4', order='F')
	X += numpy.random.normal(scale=0.1,size=[4])
	return X,T
 
# Create the neural network

src/p/y/pyfusion-HEAD/examples/test_savez.py   pyfusion(Download)
#    debug_save_compress=False;
 
global verbose
from numpy import savez, array, arange, remainder, mod, sin, pi, min, max, \
        size, diff, random, mean, unique, sort, sqrt, float32
from time import time
from pylab import plot, show
    If bits=0, find the natural accuracy.  eps defaults to 3e-6, and 
    is the error relative to the larest element, as is maxerror.
    """
    from numpy import max, std, array, min, sort, diff, unique
    if eps==0: eps=3e-6
    if maxcount==0: maxcount=10
    count=1
except: verbose=1
 
print('====== synthetic marginal precision timebase test =========')
noisytime=1+array(arange(1e4),dtype=float32)/1e6
tim=discretise_array(noisytime,eps=eps,verbose=verbose)
 
pushd=os.getcwd()

src/b/r/brian-HEAD/trunk/dev/ideas/cuda/modelfitting/example.py   brian(Download)
duration = len(I)
if kernel_run_length is None:
    kernel_run_length = duration
spiketimes = numpy.array((numpy.loadtxt('spikes_long.txt')-28.)/0.0001, dtype=int)
# we add a -10000 at the beginning as there is no previous spike at the beginning,
# and one at the end because the kernel moves to the next spike by checking for the
# 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))
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))
 
#runsim.prepare(('i', 'i', 'i', 'i'), block)

src/b/r/brian-HEAD/dev/ideas/cuda/modelfitting/example.py   brian(Download)
duration = len(I)
if kernel_run_length is None:
    kernel_run_length = duration
spiketimes = numpy.array((numpy.loadtxt('spikes_long.txt')-28.)/0.0001, dtype=int)
# we add a -10000 at the beginning as there is no previous spike at the beginning,
# and one at the end because the kernel moves to the next spike by checking for the
# 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))
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))
 
#runsim.prepare(('i', 'i', 'i', 'i'), block)

src/o/c/ocr-HEAD/pylenet/smala/examples/lid.py   ocr(Download)
def sample(lang):
	im = Image.open(names[lang][numpy.random.randint(len(names[lang]))],'r')
	X = numpy.asarray(im,dtype='f4',order='F').reshape(39,600,1)
	T = numpy.array([{'en':1,'fr':-1}[lang]], dtype='f4', order='F')
	numpy.divide(X,100.0,X)
	return X,T
 

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)
def H_fcn(x):
    H11 = -(1+cos(x[1]))**2*sin(x[0]+cos(x[1])*x[0])
    H21 = -sin(x[1]) * cos(x[0] + cos(x[1])*x[0]) \
          +sin(x[1]) *x[0]*(1+ cos(x[1]))*sin(x[0]+cos(x[1])*x[0])
    H22 = -cos(x[1])*x[0]*cos(x[0]+cos(x[1])*x[0])\
          -(sin(x[1])*x[0])**2*sin(x[0]+cos(x[1])*x[0])
    return array([[H11, H21],[H21,H22]])

src/n/i/nipy-HEAD/examples/interfaces/process_fiac.py   nipy(Download)
                'biasreg':0.0001,
                'biasfwhm':60.0,
                'samp':3.0,
                'msk':np.array([], dtype=object),
                }
            })
    run_jobdef(sninfo)
    subj['matname'][0] = matname
    roptions = {
        'preserve':False,
        'bb':np.array([[-78,-112, -50],[78,76,85.0]]),
        'vox':fltcols([2.0,2.0,2.0]),
        'interp':1.0,
        'wrap':[0.0,0.0,0.0],

src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/barb_demo.py   matplotlib(Download)
        (0.5, 0.25, 25, 15),
        (-1.5, -0.5, -5, 40)]
 
data = np.array(data, dtype=[('x', np.float32), ('y', np.float32),
    ('u', np.float32), ('v', np.float32)])
 
#Default parameters, uniform grid

src/p/y/PyPWDG-HEAD/examples/2D/adaptive.py   PyPWDG(Download)
#fb = FourierBessel(numpy.zeros(2), numpy.arange(0,1), k)
elttobasis = [[FourierBessel(c, numpy.arange(-Nfb,Nfb+1), k), PlaneWaves(dirs, k)] for c in eltcentres]
 
g = PlaneWaves(numpy.array([[3.0/5,4.0/5]]), k)
#g = FourierBessel(numpy.array([-2,-1]), numpy.array([3]),k)
#g = FourierHankel(numpy.array([-0.5,-0.2]), numpy.array([0]),k)
 
 
 
#g = BasisReduce(PlaneWaves(numpy.array([[0.6,0.8],[-0.6,0.8]]), k), numpy.array([2,1]))
#bases = [FourierHankel(c, numpy.array([0]), k) for c in numpy.array([[-0.2,0.5],[1.1,0.2]])]
#g = BasisCombine(bases, numpy.array([2,1]))
 
g = FourierHankel(numpy.array([-2.0, -1]), numpy.array([0]), k)
g = FourierHankel(numpy.array([-2.0, -1]), numpy.array([0]), k)
 
triquad = trianglequadrature(10)
bounds=numpy.array([[0,1],[0,1],[0,0]],dtype='d')
npoints=numpy.array([200,200,1])
 
filename = "adaptive"

src/n/i/NiPy-OLD-HEAD/examples/interfaces/process_fiac.py   NiPy-OLD(Download)
                'biasreg':0.0001,
                'biasfwhm':60.0,
                'samp':3.0,
                'msk':np.array([], dtype=object),
                }
            })
    run_jobdef(sninfo)
    subj['matname'][0] = matname
    roptions = {
        'preserve':False,
        'bb':np.array([[-78,-112, -50],[78,76,85.0]]),
        'vox':fltcols([2.0,2.0,2.0]),
        'interp':1.0,
        'wrap':[0.0,0.0,0.0],

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