returns a view to record array theta which behaves
    like a (N,d) float array
492780
def as_2d_array(theta):
    
    v = theta.view(np.float)
    N = theta.shape[0]
    v.shape = (N, - 1)
    # raise an error if v cannot be reshaped without creating a copy
    return v
1274767
def from_indexed_arrays(cls, name, verts, normals):
        """"""

        # Put header in string
        wavefront_str = "o {name}\n".format(name=name)


        new_verts, face_indices = face_index(verts)
        assert new_verts.shape[1] == 3, "verts should be Nx3 array"
        assert face_indices.ndim == 2

        face_indices = fan_triangulate(face_indices)

        # Write Vertex data from vert_dict
        for vert in new_verts:
            wavefront_str += "v {0} {1} {2}\n".format(*vert)

        # Write (false) UV Texture data
        wavefront_str += "vt 1.0 1.0\n"

        for norm in normals:
            wavefront_str += "vn {0} {1} {2}\n".format(*norm)

        assert len(face_indices) == len(normals) * 2
        for norm_idx, vert_idx,  in enumerate(face_indices):
            wavefront_str += "f"
            for vv in vert_idx:
                wavefront_str += " {}/{}/{}".format(vv + 1, 1, (norm_idx // 2) + 1 )
            wavefront_str += "\n"

        return cls(string=wavefront_str)
973702
def to_np(v):
    ''''''
    if isinstance(v, float): return np.array(v)
    if isinstance(v, (np.ndarray, np.generic)): return v
    if isinstance(v, (list,tuple)): return [to_np(o) for o in v]
    if isinstance(v, Variable): v=v.data
    if torch.cuda.is_available():
        if is_half_tensor(v): v=v.float()
    if isinstance(v, torch.FloatTensor): v=v.float()
    return v.cpu().numpy()
821390
def map_stack(array3D, z_function):
    
    _, _, zdim = array3D.shape
    return np.dstack([z_function(array3D[:,:,z]) for z in range(zdim)])
813993
def r_y(theta, r = Const::R_UNIT)
      r_a = Array.new

      begin
        s, c = Math.sin(theta), Math.cos(theta)
        a00 = c * r[0][0] - s * r[2][0]
        a01 = c * r[0][1] - s * r[2][1]
        a02 = c * r[0][2] - s * r[2][2]
        a20 = s * r[0][0] + c * r[2][0]
        a21 = s * r[0][1] + c * r[2][1]
        a22 = s * r[0][2] + c * r[2][2]
        r_a << [a00, a01, a02]
        r_a << r[1]
        r_a << [a20, a21, a22]
        return r_a
      rescue => e
        raise
      end
    end
629552
def array(self):
        
        return np.eye(self.M, self.N, self.k)
283831
def rotation_matrix(axis, theta):
    
    axis = np.asarray(axis)
    axis = axis / np.linalg.norm(axis)
    a = np.cos(theta / 2)
    b, c, d = -axis * np.sin(theta / 2)
    aa, bb, cc, dd = a * a, b * b, c * c, d * d
    bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
    return np.array([
        [aa + bb - cc - dd, 2 * (bc + ad), 2 * (bd - ac)],
        [2 * (bc - ad), aa + cc - bb - dd, 2 * (cd + ab)],
        [2 * (bd + ac), 2 * (cd - ab), aa + dd - bb - cc],
    ])
694892
def Rz_matrix(theta):
    """"""
    return np.array([
        [np.cos(theta), -np.sin(theta), 0],
        [np.sin(theta), np.cos(theta), 0],
        [0, 0, 1]
    ])
170401
def asarray2d(a):
    """"""
    arr = np.asarray(a)
    if arr.ndim == 1:
        arr = arr.reshape(-1, 1)
    return arr
1023671
def floatSlist(value):
    
    slist = ['+', 0, 0, 0, 0]
    if value < 0:
        slist[0] = '-'
    value = abs(value)
    for i in range(1,5):
        slist[i] = math.floor(value)
        value = (value - slist[i]) * 60
    return _roundSlist(slist)
530875
def create_theta(self):
        
        import itertools
        from pylocus.basics_angles import from_0_to_pi
        theta = np.empty((self.M, ))
        corners = np.empty((self.M, 3))
        k = 0
        indices = np.arange(self.N)
        for triangle in itertools.combinations(indices, 3):
            for counter, idx in enumerate(triangle):
                corner = idx
                other = np.delete(triangle, counter)
                corners[k, :] = [corner, other[0], other[1]]
                theta[k] = self.get_inner_angle(corner, other)
                theta[k] = from_0_to_pi(theta[k])
                if DEBUG:
                    print(self.abs_angles[corner, other[0]],
                          self.abs_angles[corner, other[1]])
                    print('theta', corners[k, :], theta[k])
                k = k + 1
            inner_angle_sum = theta[k - 1] + theta[k - 2] + theta[k - 3]
            assert abs(inner_angle_sum - pi) < 1e-10, \
                'inner angle sum: {} {} {}'.format(
                    triangle, inner_angle_sum, (theta[k - 1], theta[k - 2], theta[k - 3]))
        self.theta = theta
        self.corners = corners
        return theta, corners
1206682
def delta(n, d=None, center=0):
    
    if isinstance(n, six.integer_types):
        n = [n]
    if d is None:
        n0 = _np.asanyarray(n, dtype=_np.int32)
    else:
        n0 = _np.array(n * d, dtype=_np.int32)
    d = n0.size

    if center < 0:
        cind = [0] * d
    else:
        cind = []
        for i in xrange(d):
            cind.append(center % n0[i])
            center //= n0[i]
        if center > 0:
            cind = [0] * d
    cr = []
    for i in xrange(d):
        cur_core = _np.zeros((1, n0[i], 1))
        cur_core[0, cind[i], 0] = 1
        cr.append(cur_core)
    return _vector.vector.from_list(cr)
923742
def roty(t):
    """"""
    c = np.cos(t)
    s = np.sin(t)
    return np.array([[c,  0,  s],
                     [0,  1,  0],
                     [-s, 0,  c]])
1079993
function decodePivotArrayFloat( bundle, database, len, num_type ) {
	var ans = new NUMTYPE_CLASS[ NUMTYPE_DELTA_FLOAT.FROM[ num_type ] ]( len ),
		// pivot = bundle.readTypedNum( NUMTYPE_DELTA_FLOAT.FROM[ num_type ] ), 
		scale = bundle.readFloat64(),
		values = bundle.readTypedArray( NUMTYPE_DELTA_FLOAT.TO[ num_type ] , len );

	// console.log(">> DELTA_FLOAT len=",len,"type=",num_type,"scale=",scale,"pivot=",pivot);

	// Decode
	for (var i=0; i<len; ++i) {
		ans[i] = pivot + (values[i] * scale);
		// console.log("<<<", values[i],"->", ans[i]);
	}

	return DEBUG
		? __debugMeta( ans, 'array.delta.float', {} )
		: ans;
}
261564
def block_view(arr, block=(3, 3)):
    

    # simple shape and strides computations may seem at first strange
    # unless one is able to recognize the 'tuple additions' involved ;-)
    shape = (arr.shape[0] // block[0], arr.shape[1] // block[1]) + block
    strides = (block[0] * arr.strides[0], block[1] * arr.strides[1]) + arr.strides
    return ast(arr, shape=shape, strides=strides)
430908
def _ndarray_assoc(arr, k, v):
    ''
    arr = np.array(arr)
    arr[k] = v
    arr.setflags(write=False)
    return arr
449720
def unit_poly_verts(theta):
    
    x0, y0, r = [0.5] * 3
    verts = [(r*np.cos(t) + x0, r*np.sin(t) + y0) for t in theta]
    return verts