Skip to content
murmot

Results for “function return python array object example site:numpy.org output”

  • numpy.org

    Indexing on ndarrays — NumPy v2.5 Manual

    See Assigning values to indexed arrays for specific examples and explanations on how assignments work. Note that in Python, x[(exp1, exp2, ..., expN)] is equivalent to x[exp1, exp2, ..., expN]; the latter is just syntactic sugar for the former.

  • numpy.org

    numpy.fromfunction — NumPy v2.5 Manual

    shape(N,) tuple of ints Shape of the output array, which also determines the shape of the coordinate arrays passed to function. dtypedata-type, optional Data-type of the coordinate arrays passed to function. By default, dtype is float. likearray_like, optional Reference object to allow the creation of arrays which are not NumPy arrays.

  • numpy.org

    Interoperability with NumPy — NumPy v1.26 Manual

    Interoperability examples. Example: Pandas Series objects. Example: PyTorch tensors. Example: CuPy arrays.When NumPy functions encounter a foreign object, they will try (in order): The buffer protocol, described in the Python C-API documentation.

  • numpy.org

    Array objects — NumPy v2.5 Manual

    In addition to basic types (integers, floats, etc.), the data type objects can also represent data structures. An item extracted from an array, e.g., by indexing, is represented by a Python object whose type is one of the array scalar types built in NumPy. The array scalars allow easy manipulation of also more complicated arrangements of data.

  • numpy.org

    NumPy quickstart — NumPy v2.7.dev0 Manual

    To create sequences of numbers, NumPy provides the arange function which is analogous to the Python built-in range , but returns an array. >>> np.arange(10, 30 ...

  • numpy.org

    Interoperability with NumPy — NumPy v2.6.dev0 Manual

    1. Using arbitrary objects in NumPy#. The first set of interoperability features from the NumPy API allows foreign objects to be treated as NumPy arrays whenever possible. When NumPy functions encounter a foreign object, they will try (in order)

  • numpy.org

    numpy.array — NumPy v2.7.dev0 Manual

    An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence. If object is a scalar, a 0-dimensional array containing object is returned.

  • numpy.org

    Array creation — NumPy v2.7.dev0 Manual

    There are 6 general mechanisms for creating arrays: Conversion from other Python structures (i.e. lists and tuples). Intrinsic NumPy array creation functions ( ...

  • numpy.org

    Interoperability with NumPy — NumPy v1.24 Manual

    Interoperability examples. Example: Pandas Series objects. Example: PyTorch tensors. Example: CuPy arrays.When NumPy functions encounter a foreign object, they will try (in order): The buffer protocol, described in the Python C-API documentation.

  • numpy.org

    Standard array subclasses — NumPy v2.5 Manual

    The ndarray can be inherited from (in Python or in C) if desired. Therefore, it can form a foundation for many useful classes. Often whether to sub-class the array object or to simply use the core array component as an internal part of a new class is a difficult decision, and can be simply a matter of choice. NumPy has several tools for simplifying how your new object interacts with other ...

  • numpy.org

    Array API — NumPy v2.6.dev0 Manual

    This is the main array creation function. Most new arrays are created with this flexible function. The returned object is an object of Python-type subtype, which must be a subtype of PyArray_Type. The array has nd dimensions, described by dims.

  • numpy.org

    numpy.vectorize — NumPy v2.5 Manual

    Returns an object that acts like pyfunc, but takes arrays as input. Define a vectorized function which takes a nested sequence of objects or numpy arrays as inputs and returns a single numpy array or a tuple of numpy arrays.

  • numpy.org

    numpy.fromfunction — NumPy v2.2 Manual

    Shape of the output array, which also determines the shape of the coordinate arrays passed to function. dtypedata-type, optional. Data-type of the coordinate ...

  • numpy.org

    Subclassing ndarray — NumPy v2.6.dev0 Manual

    New from template - creating a new instance from a template instance. Examples include returning slices from a subclassed array, creating return types from ufuncs, and copying arrays. See Creating new from template for more details The last two are characteristics of ndarrays - in order to support things like array slicing.

  • numpy.org

    Array objects — NumPy v2.3 Manual

    NumPy provides an N-dimensional array type, the ndarray, which describes a collection of “items” of the same type. The items can be indexed using for example N ...