[Numpy-discussion] rank-0 arrays ideas

Travis Oliphant oliphant at ee.byu.edu
Fri Feb 18 15:05:11 CST 2005


 From the current  PEP:

 
    Proposed Solution:

        The solution proposed by this PEP is to fix the places in Python
        that could use rank-0 arrayobjects to allow for them before raising
        an exception (this will be in the core after-all).

        A Python scalar will never be returned unless explicitly
        requested.  I think this is the cleanest, easiest to understand
        and code for solution.  It may require some explicity conversion
        to int here and there, but it seems like a case of "explicit is
        better than implicit"

        Possible compromises:
            -  a compromise could be made for OBJECT arrays and
               perhaps LONG arrays if needed.

            - a special flag could be defined which is the default
              when an array of integers is constructed and which when
              set rank-0 array returns behave differently.

        It is also proposed that slicing, indexing and len() do
        not work (i.e. they raise an error) for rank-0 arrays.


Comments:

-Travis





More information about the Numpy-discussion mailing list