[Numpy-tickets] [NumPy] #866: ldexp broken

NumPy numpy-tickets@scipy....
Thu Sep 4 09:27:22 CDT 2008


#866: ldexp broken
--------------------+-------------------------------------------------------
 Reporter:  dhuard  |        Owner:  cdavid
     Type:  defect  |       Status:  new   
 Priority:  normal  |    Milestone:  1.2.0 
Component:  Other   |      Version:  devel 
 Severity:  normal  |   Resolution:        
 Keywords:          |  
--------------------+-------------------------------------------------------
Comment (by dhuard):

 In umathmodule.c.src, if I change !PyArray_INT by !PyArray_Long as in the
 following, ldexp works. This might not be THE solution, but this is as far
 as I can go for now. Here is a patch for someone familiar with ufuncs to
 review and test on a 32 bit platform.

 {{{
 Index: numpy/core/src/umathmodule.c.src
 ===================================================================
 --- numpy/core/src/umathmodule.c.src    (revision 5752)
 +++ numpy/core/src/umathmodule.c.src    (working copy)
 @@ -2187,9 +2187,9 @@
  #ifdef HAVE_FLOAT_FUNCS
      PyArray_FLOAT, PyArray_INT, PyArray_FLOAT,
  #endif
 -    PyArray_DOUBLE, PyArray_INT, PyArray_DOUBLE
 +    PyArray_DOUBLE, PyArray_LONG, PyArray_DOUBLE
  #ifdef HAVE_LONGDOUBLE_FUNCS
 -    ,PyArray_LONGDOUBLE, PyArray_INT, PyArray_LONGDOUBLE
 +    ,PyArray_LONGDOUBLE, PyArray_LONG, PyArray_LONGDOUBLE
  #endif
  };

 Index: numpy/core/tests/test_umath.py
 ===================================================================
 --- numpy/core/tests/test_umath.py      (revision 5752)
 +++ numpy/core/tests/test_umath.py      (working copy)
 @@ -47,6 +47,10 @@
          assert_almost_equal(ncu.expm1(0.2), ncu.exp(0.2)-1)
          assert_almost_equal(ncu.expm1(1e-6), ncu.exp(1e-6)-1)

 +class TestLdexp(TestCase):
 +    def test_ldexp(self):
 +        assert_almost_equal(ncu.ldexp(2., 3),  16.)
 +
  class TestMaximum(TestCase):
      def test_reduce_complex(self):
          assert_equal(ncu.maximum.reduce([1,2j]),1)

 }}}

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/866#comment:4>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list