Ticket #11334: array_interface-shape.patch

File array_interface-shape.patch, 3.6 KB (added by fbissey, 8 years ago)

add array_shape to coercion rule

  • sage/rings/complex_double.pyx

    old new  
    630630    to the rounding errors inherent to finite precision calculations.
    631631    """
    632632   
    633     __array_interface__ = {'typestr': '=c16'}
     633    __array_interface__ = {'typestr': '=c16', 'shape' : ()}
    634634   
    635635    def __cinit__(self):
    636636        self._parent = _CDF
  • sage/rings/complex_number.pyx

    old new  
    4040
    4141include "../ext/stdsage.pxi"
    4242
    43 cdef object numpy_complex_interface = {'typestr': '=c16'}
    44 cdef object numpy_object_interface = {'typestr': '|O'}
     43cdef object numpy_complex_interface = {'typestr': '=c16', 'shape' : ()}
     44cdef object numpy_object_interface = {'typestr': '|O', 'shape' : ()}
    4545
    4646cdef mp_rnd_t rnd
    4747rnd = GMP_RNDN
  • sage/rings/integer.pyx

    old new  
    172172
    173173from sage.structure.element import canonical_coercion
    174174
    175 cdef object numpy_long_interface = {'typestr': '=i4' if sizeof(long) == 4 else '=i8' }
    176 cdef object numpy_int64_interface = {'typestr': '=i8'}
    177 cdef object numpy_object_interface = {'typestr': '|O'}
     175cdef object numpy_long_interface = {'typestr': '=i4' if sizeof(long) == 4 else '=i8', 'shape' : ()}
     176cdef object numpy_int64_interface = {'typestr': '=i8', 'shape' : ()}
     177cdef object numpy_object_interface = {'typestr': '|O', 'shape' : ()}
    178178
    179179cdef mpz_t mpz_tmp
    180180mpz_init(mpz_tmp)
  • sage/rings/rational.pyx

    old new  
    7878cdef sage.rings.fast_arith.arith_int ai
    7979ai = sage.rings.fast_arith.arith_int()
    8080
    81 cdef object numpy_long_interface = {'typestr': '=i4' if sizeof(long) == 4 else '=i8' }
    82 cdef object numpy_int64_interface = {'typestr': '=i8'}
    83 cdef object numpy_object_interface = {'typestr': '|O'}
    84 cdef object numpy_double_interface = {'typestr': '=f8'}
     81cdef object numpy_long_interface = {'typestr': '=i4' if sizeof(long) == 4 else '=i8', 'shape' : ()}
     82cdef object numpy_int64_interface = {'typestr': '=i8', 'shape' : ()}
     83cdef object numpy_object_interface = {'typestr': '|O', 'shape' : ()}
     84cdef object numpy_double_interface = {'typestr': '=f8', 'shape' : ()}
    8585
    8686cdef extern from "convert.h":
    8787    ctypedef long* GEN   
  • sage/rings/real_double.pyx

    old new  
    3030    Test NumPy conversions::
    3131   
    3232        sage: RDF(1).__array_interface__
    33         {'typestr': '=f8'}
     33        {'typestr': '=f8', 'shape' : ()}
    3434        sage: import numpy
    3535        sage: numpy.array([RDF.pi()]).dtype
    3636        dtype('float64')
     
    531531    the rounding errors inherent to finite precision calculations.
    532532    """
    533533   
    534     __array_interface__ = {'typestr': '=f8'}
     534    __array_interface__ = {'typestr': '=f8', 'shape' : ()}
    535535   
    536536    def __cinit__(self):
    537537        (<Element>self)._parent = _RDF
  • sage/rings/real_mpfr.pyx

    old new  
    167167
    168168_re_skip_zeroes = re.compile(r'^(.+?)0*$')
    169169
    170 cdef object numpy_double_interface = {'typestr': '=f8'}
    171 cdef object numpy_object_interface = {'typestr': '|O'}
     170cdef object numpy_double_interface = {'typestr': '=f8', 'shape' : ()}
     171cdef object numpy_object_interface = {'typestr': '|O', 'shape' : ()}
    172172
    173173# Avoid signal handling for cheap operations when the
    174174# precision is below this threshold.