Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update numpy to 1.7.0 #11334

Closed
jasongrout opened this issue May 14, 2011 · 151 comments
Closed

Update numpy to 1.7.0 #11334

jasongrout opened this issue May 14, 2011 · 151 comments

Comments

@jasongrout
Copy link
Member

Numpy-1.7.0 is now available and fixes the coercion problem that prevented us to go to numpy-1.6.x.

New spkg: http://spkg-upload.googlecode.com/files/numpy-1.7.0.spkg

Apply:

Depends on #12415
Depends on #13992

Upstream: Fixed upstream, in a later stable release.

CC: @kiwifb @kini @SnarkBoojum

Component: packages: standard

Keywords: sd40.5

Author: François Bissey

Reviewer: Steven Trogdon, Jeroen Demeyer

Merged: sage-5.10.beta0

Issue created by migration from https://trac.sagemath.org/ticket/11334

@jasongrout
Copy link
Member Author

comment:1

CCing fbissey since he's been extremely helpful in previous numpy upgrades.

@kiwifb
Copy link
Member

kiwifb commented May 15, 2011

comment:2

Thx. it looks like numpy has been bumped to 1.6 in Gentoo so I can do some quick compatibility tests. It looks like a flag for gfortran has been added in the ebuild to help with the compiler autodetection madness it may be worth having it sage side too.

Do you know if a scipy release is to follow, if not it would be best to revbump scipy to make sure it is rebuilt after numpy.

Other matter there has been noise about lapack in numpy do we want to disable it, make it optional or keep the status quo?

@jasongrout
Copy link
Member Author

comment:3

I don't remember seeing anything on the scipy lists about an imminent scipy release.

@kiwifb
Copy link
Member

kiwifb commented May 15, 2011

comment:4

just in:

sage -t  -long -force_lib "devel/sage/doc/en/numerical_sage/numpy.rst"
**********************************************************************
File "/usr/share/sage/devel/sage/doc/en/numerical_sage/numpy.rst", line 97:
    sage: 2.5*l
Expected:
    array([  0. ,   2.5,   5. ,   7.5,  10. ,  12.5,  15. ,  17.5,  20. ,  22.5])
Got:
    array([0.000000000000000, 2.50000000000000, 5.00000000000000,
           7.50000000000000, 10.0000000000000, 12.5000000000000,
           15.0000000000000, 17.5000000000000, 20.0000000000000,
           22.5000000000000], dtype=object)
**********************************************************************
File "/usr/share/sage/devel/sage/doc/en/numerical_sage/numpy.rst", line 289:
    sage: xx
Expected:
    array([[ 0.  ,  0.25,  0.5 ,  0.75,  1.  ],
           [ 0.  ,  0.25,  0.5 ,  0.75,  1.  ],
           [ 0.  ,  0.25,  0.5 ,  0.75,  1.  ],
           [ 0.  ,  0.25,  0.5 ,  0.75,  1.  ],
           [ 0.  ,  0.25,  0.5 ,  0.75,  1.  ]])
Got:
    array([[0.000000000000000, 0.250000000000000, 0.500000000000000,
            0.750000000000000, 1.00000000000000],
           [0.000000000000000, 0.250000000000000, 0.500000000000000,
            0.750000000000000, 1.00000000000000],
           [0.000000000000000, 0.250000000000000, 0.500000000000000,
            0.750000000000000, 1.00000000000000],
           [0.000000000000000, 0.250000000000000, 0.500000000000000,
            0.750000000000000, 1.00000000000000],
           [0.000000000000000, 0.250000000000000, 0.500000000000000,
            0.750000000000000, 1.00000000000000]], dtype=object)
**********************************************************************
File "/usr/share/sage/devel/sage/doc/en/numerical_sage/numpy.rst", line 295:
    sage: yy
Expected:
    array([[ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
           [ 0.25,  0.25,  0.25,  0.25,  0.25],
           [ 0.5 ,  0.5 ,  0.5 ,  0.5 ,  0.5 ],
           [ 0.75,  0.75,  0.75,  0.75,  0.75],
           [ 1.  ,  1.  ,  1.  ,  1.  ,  1.  ]])
Got:
    array([[0.000000000000000, 0.000000000000000, 0.000000000000000,
            0.000000000000000, 0.000000000000000],
           [0.250000000000000, 0.250000000000000, 0.250000000000000,
            0.250000000000000, 0.250000000000000],
           [0.500000000000000, 0.500000000000000, 0.500000000000000,
            0.500000000000000, 0.500000000000000],
           [0.750000000000000, 0.750000000000000, 0.750000000000000,
            0.750000000000000, 0.750000000000000],
           [1.00000000000000, 1.00000000000000, 1.00000000000000,
            1.00000000000000, 1.00000000000000]], dtype=object)
**********************************************************************
File "/usr/share/sage/devel/sage/doc/en/numerical_sage/numpy.rst", line 301:
    sage: f(xx,yy)
Expected:
    array([[ 0.    ,  0.0625,  0.25  ,  0.5625,  1.    ],
           [ 0.0625,  0.125 ,  0.3125,  0.625 ,  1.0625],
           [ 0.25  ,  0.3125,  0.5   ,  0.8125,  1.25  ],
           [ 0.5625,  0.625 ,  0.8125,  1.125 ,  1.5625],
           [ 1.    ,  1.0625,  1.25  ,  1.5625,  2.    ]])
Got:
    array([[0.000000000000000, 0.0625000000000000, 0.250000000000000,
            0.562500000000000, 1.00000000000000],
           [0.0625000000000000, 0.125000000000000, 0.312500000000000,
            0.625000000000000, 1.06250000000000],
           [0.250000000000000, 0.312500000000000, 0.500000000000000,
            0.812500000000000, 1.25000000000000],
           [0.562500000000000, 0.625000000000000, 0.812500000000000,
            1.12500000000000, 1.56250000000000],
           [1.00000000000000, 1.06250000000000, 1.25000000000000,
            1.56250000000000, 2.00000000000000]], dtype=object)
**********************************************************************
2 items had failures:
   1 of  55 in __main__.example_0
   3 of  13 in __main__.example_1
***Test Failed*** 4 failures.

there may be more

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member

kiwifb commented May 15, 2011

comment:5

I have cut a new spkg for 1.6.0, I decided to go for plain update for now.

@kiwifb
Copy link
Member

kiwifb commented May 16, 2011

comment:6

seems my home install has problems. Probably stuff messed around between python 2.6 and 2.7 because I am working on #9958. Another install didn't report any problems. So I will check on a vanilla sage but I think we won't need to do any patching.

@kiwifb
Copy link
Member

kiwifb commented May 16, 2011

comment:7

For some reason the other install didn't upgrade that's why I didn't see anything on the second machine. So right now it looks like we have the following to correct:

        sage -t  -long -force_lib devel/sage/doc/en/numerical_sage/numpy.rst #
 4 doctests failed
         sage -t  -long -force_lib devel/sage/sage/symbolic/function.pyx # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/plot/plot_field.py # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/plot/matrix_plot.py # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/matrix/matrix1.pyx # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/numerical/optimize.py # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/rings/integer.pyx # 1
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/functions/hyperbolic.py # 2
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/functions/trig.py # 3
 doctests failed
         sage -t  -long -force_lib devel/sage/sage/functions/other.py # 2
 doctests failed

The first one is already in the ticket, then we have

sage -t -long -force_lib "devel/sage/sage/symbolic/function.pyx"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/symbolic/function.pyx", line 596:
    sage: csc(a)
Expected:
    array([        inf,  1.18839511,  1.09975017,  7.0861674 , -1.32134871])
Got:
    doctest:270: RuntimeWarning: divide by zero encountered in divide
    array([        inf,  1.18839511,  1.09975017,  7.0861674 , -1.32134871])
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/plot/plot_field.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/plot/plot_field.py", line 216:
    sage: plot_slope_field(growth_rate*(1-y/capacity)*y, (x,0,5), (y,0,capacity*2)).show(aspect_ratio=1)
Expected nothing
Got:
    doctest:622: RuntimeWarning: divide by zero encountered in divide
    doctest:623: RuntimeWarning: invalid value encountered in multiply
    doctest:624: RuntimeWarning: invalid value encountered in multiply
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/plot/matrix_plot.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/plot/matrix_plot.py", line 383:
    sage: matrix_plot([[sin(x), cos(x)], [1, 0]])
Expected:
    Traceback (most recent call last):
    ...
    ValueError: can not convert entries to floating point numbers
Got:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_8[36]>", line 1, in <module>
        matrix_plot([[sin(x), cos(x)], [Integer(1), Integer(0)]])###line 383:
    sage: matrix_plot([[sin(x), cos(x)], [1, 0]])
      File "/usr/lib/python2.7/site-packages/sage/misc/decorators.py", line 381, in wrapper
        return func(*args, **kwds)
      File "/usr/lib/python2.7/site-packages/sage/misc/decorators.py", line 432, in wrapper
        return func(*args, **options)
      File "/usr/lib/python2.7/site-packages/sage/plot/matrix_plot.py", line 423, in matrix_plot
        raise TypeError, "mat must be a Matrix or a two dimensional array"
    TypeError: mat must be a Matrix or a two dimensional array
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/matrix/matrix1.pyx"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/matrix/matrix1.pyx", line 468:
    sage: sorted(numpy.typecodes.items())
Expected:
    [('All', '?bhilqpBHILQPfdgFDGSUVO'), ('AllFloat', 'fdgFDG'), ('AllInteger', 'bBhHiIlLqQpP'), ('Character', 'c'), ('Complex', 'FDG'), ('Float', 'fdg'), ('Integer', 'bhilqp'), ('UnsignedInteger', 'BHILQP')]
Got:
    [('All', '?bhilqpBHILQPefdgFDGSUVOMm'), ('AllFloat', 'efdgFDG'), ('AllInteger', 'bBhHiIlLqQpP'), ('Character', 'c'), ('Complex', 'FDG'), ('Datetime', 'Mm'), ('Float', 'efdg'), ('Integer', 'bhilqp'), ('UnsignedInteger', 'BHILQP')]
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/numerical/optimize.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/numerical/optimize.py", line 162:
    sage: find_minimum_on_interval(f, 1, 5, tol=1e-3)
Expected:
    (-3.28837136189098..., 3.42575079030572...)
Got:
    (-3.28837136189, 3.4257507903057229)
sage -t -long -force_lib "devel/sage/sage/rings/integer.pyx"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/rings/integer.pyx", line 4738:
    sage: numpy.array(2**40).dtype
Expected:
    dtype('int64')
Got:
    dtype('object')
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/functions/hyperbolic.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/hyperbolic.py", line 609:
    sage: arcsech(a)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_23[4]>", line 1, in <module>
        arcsech(a)###line 609:
    sage: arcsech(a)
      File "function.pyx", line 357, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:3794)
      File "/usr/lib/python2.7/site-packages/sage/functions/hyperbolic.py", line 612, in _eval_numpy_
        return arccosh(1.0 / x)
    ZeroDivisionError: float division by zero
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/hyperbolic.py", line 658:
    sage: arccsch(a)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_26[4]>", line 1, in <module>
        arccsch(a)###line 658:
    sage: arccsch(a)
      File "function.pyx", line 357, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:3794)
      File "/usr/lib/python2.7/site-packages/sage/functions/hyperbolic.py", line 661, in _eval_numpy_
        return arcsinh(1.0 / x)
    ZeroDivisionError: float division by zero
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/functions/trig.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/trig.py", line 827:
    sage: atan2(a, b)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_34[16]>", line 1, in <module>
        atan2(a, b)###line 827:
    sage: atan2(a, b)
      File "function.pyx", line 718, in sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/function.cpp:6475)
      File "function.pyx", line 357, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:3794)
      File "function.pyx", line 604, in sage.symbolic.function.Function._eval_numpy_ (sage/symbolic/function.cpp:5568)
    NotImplementedError: The Function arctan2 does not support numpy arrays as arguments
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/trig.py", line 830:
    sage: atan2(1,a)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_34[17]>", line 1, in <module>
        atan2(Integer(1),a)###line 830:
    sage: atan2(1,a)
      File "function.pyx", line 718, in sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/function.cpp:6475)
      File "function.pyx", line 357, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:3794)
      File "function.pyx", line 604, in sage.symbolic.function.Function._eval_numpy_ (sage/symbolic/function.cpp:5568)
    NotImplementedError: The Function arctan2 does not support numpy arrays as arguments
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/trig.py", line 833:
    sage: atan2(a, 1)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_34[18]>", line 1, in <module>
        atan2(a, Integer(1))###line 833:
    sage: atan2(a, 1)
      File "function.pyx", line 718, in sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/function.cpp:6475)
      File "function.pyx", line 357, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:3794)
      File "function.pyx", line 604, in sage.symbolic.function.Function._eval_numpy_ (sage/symbolic/function.cpp:5568)
    NotImplementedError: The Function arctan2 does not support numpy arrays as arguments
**********************************************************************
sage -t -long -force_lib "devel/sage/sage/functions/other.py"
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/other.py", line 211:
    sage: ceil(a)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_5[20]>", line 1, in <module>
        ceil(a)###line 211:
    sage: ceil(a)
      File "/usr/lib/python2.7/site-packages/sage/functions/other.py", line 251, in __call__
        return numpy.ceil(x)
    AttributeError: ceil
**********************************************************************
File "/usr/share/sage/devel/sage/sage/functions/other.py", line 366:
    sage: floor(a)
Exception raised:
    Traceback (most recent call last):
      File "/usr/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/usr/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/usr/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_9[15]>", line 1, in <module>
        floor(a)###line 366:
    sage: floor(a)
      File "/usr/lib/python2.7/site-packages/sage/functions/other.py", line 405, in __call__
        return numpy.floor(x)
    AttributeError: floor
**********************************************************************

The last three are particularly concerning, could you check what's up with these in numpy?

@kcrisman
Copy link
Member

comment:8

This seems to have installed fine on OS X 10.4 PPC. I'm running doctests now (which will take a LONG time) but I did already see the matrix/matrix1.pyx one while testing something else.

@kiwifb
Copy link
Member

kiwifb commented Jun 30, 2011

comment:9

That's good that it at least install. On gentoo there are interactions problem between numpy and scipy to get cblas/blas/lapack right in scipy. I should check if the resulting scipy in vanilla sage suffers from the same problem.
http://bugs.gentoo.org/show_bug.cgi?id=371099

The last few failing tests are show stoppers as far as I am concerned.

@kcrisman
Copy link
Member

kcrisman commented Jul 5, 2011

comment:10

Okay, I got pretty much the same failures on a long run. One weird thing... did we change find_minimum_on_interval away from SciPy recently? This is the full output I get on the (otherwise same as your failure) test for that.

    sage: find_minimum_on_interval(f, 1, 5, tol=1e-3)
Expected:
    (-3.28837136189098..., 3.42575079030572...)
Got:
    (-3.28837136189, 3.4257507903057229)
GLPK Simplex Optimizer, v4.44
6 rows, 3 columns, 8 non-zeros
Preprocessing...
2 rows, 2 columns, 4 non-zeros
Scaling...
 A: min|aij| =  2.400e+01  max|aij| =  5.000e+01  ratio =  2.083e+00
GM: min|aij| =  8.128e-01  max|aij| =  1.230e+00  ratio =  1.514e+00
EQ: min|aij| =  6.606e-01  max|aij| =  1.000e+00  ratio =  1.514e+00
Constructing initial basis...
Size of triangular part = 2
*     0: obj =  -5.100000000e+01  infeas =  0.000e+00 (0)
*     1: obj =  -5.225000000e+01  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND

@kiwifb
Copy link
Member

kiwifb commented Jul 31, 2011

comment:11

1.6.1 is now available. I'll have a look sometimes this week.

@kiwifb
Copy link
Member

kiwifb commented Aug 8, 2011

comment:12

Looks like more of the same but maybe a little bit more. There are a few other things that may interfere on my setup and I had to solve that bit:
http://bugs.gentoo.org/show_bug.cgi?id=371099 before doing the trial.

@kiwifb
Copy link
Member

kiwifb commented Aug 8, 2011

comment:13

Once I had cleared a few blas problem that I had while solving the gentoo bug. I get exactly the same results. I also get the output from Karl in optimize. This is a verbose output of glpk which get called at some point. You only get to see the such verbose output if there was a failure in the test but not necessarily the test for which glpk is called funnily enough.

@kiwifb
Copy link
Member

kiwifb commented Nov 25, 2011

comment:14

Should we try to move forward on this again? I will have a go at trying it with 4.8.alpha2. Any ideas about the current failures?

@kiwifb
Copy link
Member

kiwifb commented Nov 28, 2011

comment:15

Ok this is still broken in 4.8.alpha2. Some food for thought

sage
----------------------------------------------------------------------
| Sage Version 4.8.alpha2, Release Date: 2011-11-19                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
sage: import numpy
sage: a = numpy.linspace(0,2,6)
sage: a
array([0.0, 0.4, 0.8, 1.2, 1.6, 2], dtype=object)
sage: ceil(a)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/fbissey/<ipython console> in <module>()

/usr/lib64/python2.7/site-packages/sage/functions/other.py in __call__(self, x, maximum_bits)
    250             elif type(x).__module__ == 'numpy':
    251                 import numpy
--> 252                 return numpy.ceil(x)
    253 
    254         x_original = x

AttributeError: ceil

with numpy-1.5.1 we just have

sage: a
array([0.0, 0.4, 0.8, 1.2, 1.6, 2])

I suspect that for this one (functions/other.py) and functions/trig.py the pynac interface may need to be touched. All stuff that takes an numpy array and return a numpy array may have trouble.

@kiwifb
Copy link
Member

kiwifb commented Nov 28, 2011

comment:16

Just to add a bit of info. Same python and ipython

ipython
Python 2.7.2 (default, Oct 28 2011, 11:36:16) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import numpy

In [2]: a = numpy.linspace(0,2,6)

In [3]: a
Out[3]: array([ 0. ,  0.4,  0.8,  1.2,  1.6,  2. ])

In [4]: ceil(a)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/fbissey/<ipython console> in <module>()

NameError: name 'ceil' is not defined

In [5]: numpy.ceil(a)
Out[5]: array([ 0.,  1.,  1.,  2.,  2.,  2.])

So it works in ipython but we don't have the dtype=object attached to the array. Anyone knows what that means actually?

@kiwifb
Copy link
Member

kiwifb commented Nov 28, 2011

comment:17

numpy-1.5.1

sage: numpy.dtype(a[1])
dtype('float64')

numpy-1.6.1

sage: numpy.dtype(a[1])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/fbissey/<ipython console> in <module>()

TypeError: data type not understood

@kiwifb
Copy link
Member

kiwifb commented Nov 28, 2011

comment:18
sage: type(a[0])
<type 'float'>
sage: type(a[0:5])
<type 'numpy.ndarray'>
sage: type(a[2])
<type 'float'>
sage: type(a[3])
<type 'float'>
sage: type(a[4])
<type 'float'>
sage: type(a[5])
<type 'sage.rings.integer.Integer'>

For some reason numpy.linspace return an array with sage objects rather than just floats. I am guessing it may be deeper than that. Numpy probably uses sage types rather than converting to numpy types. The types of a[0] to a[4] is strange, is there a sage type for floats? I mean I tried numpy.linspace(0,2.0,6) and I got <type 'sage.rings.real_mpfr.RealNumber'> for a[0] to a[4] and <type 'sage.rings.real_mpfr.RealLiteral'> for a[5].

Doing a cast numpy.array(a,dtype=float) returns something that will work.

@kiwifb

This comment has been minimized.

@kiwifb kiwifb changed the title Update numpy to 1.6 Update numpy to 1.6.1 Jan 11, 2012
@kiwifb
Copy link
Member

kiwifb commented Jan 17, 2012

comment:20

I'll be starting to make patches to correct the doctests and document the new behavior in numpy 1.6.x. Some documentation may need updating.

@kiwifb
Copy link
Member

kiwifb commented Jan 17, 2012

comment:21

Actually I am a bit confused by one of the tests:

    ``plot_slope_field`` takes a function of two variables xvar and yvar
    (for instance, if the variables are `x` and `y`, take `f(x,y)`), and at
    representative points `(x_i,y_i)` between xmin, xmax, and ymin, ymax
    respectively, plots a line with slope `f(x_i,y_i)` (see below).

    ``plot_slope_field(f, (xvar, xmin, xmax), (yvar, ymin, ymax))``

    EXAMPLES: 

    A logistic function modeling population growth::

        sage: x,y = var('x y')
        sage: capacity = 3 # thousand
        sage: growth_rate = 0.7 # population increases by 70% per unit of time
        sage: plot_slope_field(growth_rate*(1-y/capacity)*y, (x,0,5), (y,0,capacity*2))

That function is independent of x, the next example after this depend on both x and y. I am suspecting the messages we get in this particular case is quite justified and it is surprising we didn't get any before. I am not sure what the correct formula should be.

@kiwifb
Copy link
Member

kiwifb commented Jan 17, 2012

comment:22

I am guessing it should have been

growth_rate*(1-x/capacity)*y

y being the time and x the population in thousands. That satisfy a simple dimensional analysis.

@jasongrout
Copy link
Member Author

comment:23

No, wasn't it right before? That's the standard logistic population model, where y is the population. See http://en.wikipedia.org/wiki/Logistic_function#In_ecology:_modeling_population_growth, for example.

@kcrisman
Copy link
Member

comment:24
sage: plot_slope_field(growth_rate*(1-y/capacity)*y, (x,0,5), (y,0,capacity*2))
}}}}
> That function is independent of x, the next example after this depend on both x and y. I am suspecting the messages we get in

This should be ok. The point is that the slope dy/dx is a function of y only; this can be completely symbolically solved using separation of variables to get the [http://en.wikipedia.org/wiki/Logistic_function#In_ecology:_modeling_population_growth logistic function].

> this particular case is quite justified and it is surprising we didn't get any before. I am not sure what the correct formula should be.

If this is the division by zero stuff, it's the whole business with the arrowheads having zero length. See #11208. I think Jason has a fix for this, actually, but I don't recall the whole story of what happened once it was reported to mpl.

@kcrisman
Copy link
Member

comment:25

Sorry for that noise. Jason is right.

sage: plot_slope_field(growth_rate*(1-y/capacity)*y, (x,0,5), (y,0,capacity*2))

That function is independent of x, the next example after this depend on both x and y. I am suspecting the messages we get in

This should be ok. The point is that the slope dy/dx is a function of y only; this can be completely symbolically solved using separation of variables to get the logistic function.

this particular case is quite justified and it is surprising we didn't get any before. I am not sure what the correct formula should be.

If this is the division by zero stuff, it's the whole business with the arrowheads having zero length. See #11208. I think Jason has a fix for this, actually, but I don't recall the whole story of what happened once it was reported to mpl.

@kiwifb
Copy link
Member

kiwifb commented Apr 4, 2013

suppress divide warnings in riemann.pyx

@strogdon
Copy link

strogdon commented Apr 4, 2013

comment:117

Attachment: trac_11334-suppressdivide.patch.gz

OK, so the above RuntimeWarnings are bogus and don't appear when things are built correctly (from scratch). Curiously,

sage -t --long devel/sage/sage/calculus/riemann.pyx

does not fail when testing using 'make ptestlong', but does yield the 'divide by zero' warning when run individually.

@kiwifb
Copy link
Member

kiwifb commented Apr 5, 2013

comment:118

Yes very curious things like that happens. I am preparing a new set of patch with a different strategy to deal with riemann.pyx. I already uploaded one but I need to make a new patch for other divide warnings not coming from riemann.pyx - people willingly wanting to see 1/0 results.

@kiwifb
Copy link
Member

kiwifb commented Apr 5, 2013

Attachment: trac_11334-divide-v2.patch.gz

fix non riemann.pyx divivde by zero warnings

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member

kiwifb commented Apr 5, 2013

comment:119

OK new patch set. If that doesn't work for you we have a serious problem. Back to need review.

@strogdon
Copy link

strogdon commented Apr 5, 2013

Reviewer: Steven Trogdon

@strogdon
Copy link

strogdon commented Apr 5, 2013

comment:120

It's odd that one has to resort to such "trickery" to ignore warnings. However, it is not without warrant since the ignore mechanism was already operative at a certain level in riemann.pyx. This works for me here - all "divide by zero" warnings have been removed from output and everything survives make ptestlong. Positive review.

@kiwifb
Copy link
Member

kiwifb commented Apr 6, 2013

comment:121

I suspect the strange behavior we have seen may be a symptom of something deeper on the way the doctesting framework deals with warnings. Anyway it should be sorted by that last couple of patch for this case.

@jdemeyer jdemeyer modified the milestones: sage-5.9, sage-5.10 Apr 6, 2013
@jdemeyer
Copy link

jdemeyer commented Apr 7, 2013

Author: François Bissey

@jdemeyer
Copy link

comment:124

Attachment: 11334_noise2.patch.gz

attachment: 11334_noise2.patch (numerical noise on OS X 10.8) needs review.

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member

kiwifb commented Apr 14, 2013

comment:126

When I first saw that I was wondering if it was a combination with python 2.7.4 but I haven't conducted any test on OS X 10.8. The patch looks fine to me and is compatible with the rest. I am taking it as a reviewer patch and putting this back to positive review.

@kiwifb
Copy link
Member

kiwifb commented Apr 14, 2013

Changed reviewer from Steven Trogdon to Steven Trogdon, Jeroen Demeyer

@jdemeyer
Copy link

Merged: sage-5.10.beta0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants