How to use the scipy.array function in scipy

To help you get started, we’ve selected a few scipy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Gjacquenot / Puma-EM / code / FMM_Znear.py View on Github external
def Z_nearPerCube(path, cube, CFIE, cubeNumber, w, eps_r, mu_r, ELEM_TYPE, Z_TMP_ELEM_TYPE, TDS_APPROX, Z_s, MOM_FULL_PRECISION):
    """this function computes the part of the MoM Z matrix corresponding to
    the cube 'cubeNumber' as the observer cube and all its neighbors cubes,
    including itself, as the source cubes."""
    # call of the C++ routine for computing the interaction matrix
    Z_CFIE_near_local = Z_MoM_triangles_arraysFromCube(cube, CFIE, w, eps_r, mu_r, TDS_APPROX, Z_s, MOM_FULL_PRECISION)
    # we create a 1-D array out of Z_CFIE_near_local
    Z_CFIE_nearPerCube = array(Z_CFIE_near_local.astype(ELEM_TYPE).flat)
    writeBlitzArrayToDisk(Z_CFIE_near_local.astype(Z_TMP_ELEM_TYPE), os.path.join(path, str(cubeNumber)))
    return Z_CFIE_nearPerCube
github pybrain / pybrain / pybrain / tools / rankingfunctions.py View on Github external
def normalizedFitness(R):
    return array((R - mean(R)) / sqrt(var(R))).flatten()
github josephwilk / semanticpy / semanticpy / transform / transform.py View on Github external
def __init__(self, matrix):
        self.matrix = array(matrix, dtype=float)
github pybrain / pybrain / pybrain / rl / agents / egreedy.py View on Github external
def getAction(self):
        """ activates the module with the last observation and stores the result as last action. """
        # get greedy action
        action = LearningAgent.getAction(self)
        
        # explore by chance
        if random.random() < self.epsilon:
            action = array([random.randint(self.module.numActions)])
        
        # reduce epsilon
        self.epsilon *= self.epsilondecay
        
        return action
github cbick / gps2gtfs / postprocessing / src / Stats.py View on Github external
cdf_dict = { "Second stop" : stop_num_split[(1,)],
               "Middle stop" : halfway_split[(50,)]+halfway_split[(51,)],
               "Next to last stop" : end_num_split[(1,)] }
  compare_ecdfs("Stop Position",cdf_dict);

  # Plot E vs stop number
  Es = []
  moes = []
  sns = array([k[0] for k in stop_num_split.keys()])
  sns.sort()
  for sn in sns:
    rowdata = array([(r['lateness'],r['trip_stop_weight']) for r in stop_num_split[(sn,)]])
    Eval,moe = E(rowdata,weighted=True)
    Es.append(Eval)
    moes.append(moe)
  Es = array(Es)
  moes = array(moes)
  
  figure()
  plot(sns,Es,'k-',label="Estimated expectation")
  plot(sns,Es+moes,'k--',label=None)
  plot(sns,Es-moes,'k--',label=None)
  #legend()
  xlabel("Stop Number")
  ylabel("Expected Latenes")
  title("Expected Lateness vs Stop Number")
github amilsted / evoMPS / evoMPS / tdvp_uniform.py View on Github external
if nb is None:
            nb = d + 1

        if s2 is None:
            A2 = self.A[0]
        else:
            A2 = s2.A[0]
        As = [self.A[0]] * nb + [B] + [A2] * (2*d + 1 - nb)
        
        ls, rs = self._get_tangent_lr(B, d, op1=op1, nb=nb, s2=s2)
        g = [m.adot(ls[0], tm.eps_r_op_1s(rs[1], As[1], As[1], op1.dot(op2)))]
        g += [m.adot(ls[n - 1], tm.eps_r_op_1s(rs[n], As[n], As[n], op2)) 
              for n in range(2, 2*d + 2)]
        
        g = sp.array(g)
        
        c = g - exs1 * exs2
                   
        return c, g
github PMBio / pygp / trunk / pygp / covar / __init__.py View on Github external
def get_default_hyperparameters(self,x=None,y=None):
        """
        Return default hyperpameters.
        
        *Default:*: No hyperparameters; Returns an empty array.
        """
        return {'covar':SP.array([])}
github PMBio / pygp / gpr_plot.py View on Github external
Input x (e.g. time).

    y : [double]
        Output y (e.g. expression).

    shift : [double]
        The shift of each replicate group.
        
    replicate_indices : [int]
        Indices of replicates for each x, rexpectively

    format_data : {format}
        Format of the data points. See Matplotlib for details. 
    """
    x = S.array(x).reshape(-1)
    y = S.array(y).reshape(-1)

    x_shift = x.copy()

    if shift is not None and replicate_indices is not None:
        assert len(shift)==len(S.unique(replicate_indices)), 'Need one shift per replicate to plot properly'

        _format_data = format_data.copy()
        _format_data['alpha'] = .2
        PL.plot(x,y,**_format_data)

        for i in S.unique(replicate_indices):
            x_shift[replicate_indices==i] -= shift[i]

        for i in xrange(len(x)):
            PL.annotate("",xy=(x_shift[i],y[i]),
                        xytext=(x[i],y[i]),
github nipy / pbrain / build / lib / eegview / plane_widgets.py View on Github external
def scroll_depth(self, step):
        # step along the normal
        p1 = array(self.pw.GetPoint1())
        p2 = array(self.pw.GetPoint2())

        origin = self.pw.GetOrigin()
        normal = self.pw.GetNormal()
        newPlane = vtk.vtkPlane()
        newPlane.SetNormal(normal)
        newPlane.SetOrigin(origin)
        newPlane.Push(step)
        newOrigin = newPlane.GetOrigin()

        delta = array(newOrigin) - array(origin) 
        p1 += delta
        p2 += delta
            
        self.pw.SetPoint1(p1)
        self.pw.SetPoint2(p2)
        self.pw.SetOrigin(newOrigin)
        self.pw.UpdatePlacement()
        self.update_plane()