Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#6494 closed defect (invalid)

sage should *never* ever import numpy by default on startup. Yet again it does!

Reported by: William Stein Owned by: Michael Abshoff
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: packages: standard Keywords:
Cc: William Stein, Jason Grout, Robert Bradshaw Merged in:
Authors: Reviewers: Mike Hansen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Jeroen Demeyer)

$ ./sage -startuptime |grep numpy
         decorators_numpy: 0.000 (IPython.testing)
                 numpy: 0.056 (complex_plot)
                  numpy.__config__: 0.000 (numpy)
                  version: 0.000 (numpy)
                  _import_tools: 0.000 (numpy)
                  add_newdocs: 0.035 (numpy)
                   numpy.lib: 0.026 (add_newdocs)
                    info: 0.000 (numpy.lib)
                    numpy.version: 0.000 (numpy.lib)
                    type_check: 0.016 (numpy.lib)
                     numpy.core.numeric: 0.015 (type_check)
                      multiarray: 0.001 (numpy.core.numeric)
                      umath: 0.001 (numpy.core.numeric)
                       numpy.core.multiarray: 0.000 (umath)
                      _internal: 0.002 (numpy.core.numeric)
                       numpy.compat: 0.000 (_internal)
                        _inspect: 0.000 (numpy.compat)
                        py3k: 0.000 (numpy.compat)
                      numerictypes: 0.001 (numpy.core.numeric)
                      _sort: 0.000 (numpy.core.numeric)
                      numeric: 0.002 (numpy.core.numeric)
                      defchararray: 0.001 (numpy.core.numeric)
                      records: 0.000 (numpy.core.numeric)
                      memmap: 0.000 (numpy.core.numeric)
                      scalarmath: 0.000 (numpy.core.numeric)
                       numpy.core.umath: 0.000 (scalarmath)
                      function_base: 0.000 (numpy.core.numeric)
                      machar: 0.000 (numpy.core.numeric)
                       numpy.core.fromnumeric: 0.000 (machar)
                      getlimits: 0.000 (numpy.core.numeric)
                      shape_base: 0.000 (numpy.core.numeric)
                      numpy.testing: 0.005 (numpy.core.numeric)
                       numpy.testing.utils: 0.004 (numpy.testing)
                        nosetester: 0.003 (numpy.testing.utils)
                       utils: 0.000 (numpy.testing)
                       numpytest: 0.000 (numpy.testing)
                    index_tricks: 0.004 (numpy.lib)
                     numpy.core.numerictypes: 0.000 (index_tricks)
                     numpy.core: 0.000 (index_tricks)
                     numpy.lib.twodim_base: 0.000 (index_tricks)
                      numpy.lib.utils: 0.001 (arraysetops)
                     numpy.matrixlib: 0.001 (index_tricks)
                      defmatrix: 0.001 (numpy.matrixlib)
                    stride_tricks: 0.000 (numpy.lib)
                    twodim_base: 0.000 (numpy.lib)
                    scimath: 0.000 (numpy.lib)
                     numpy.lib.type_check: 0.000 (scimath)
                    numpy.lib.function_base: 0.000 (numpy.lib)
                    numpy.linalg: 0.003 (numpy.lib)
                     linalg: 0.003 (numpy.linalg)
                      numpy.matrixlib.defmatrix: 0.000 (linalg)
                    npyio: 0.002 (numpy.lib)
                    financial: 0.000 (numpy.lib)
                    arrayterator: 0.000 (numpy.lib)
                   numpy.lib._compiled_base: 0.000 (add_newdocs)
                   numpy.lib.index_tricks: 0.000 (add_newdocs)
                  testing: 0.000 (numpy)
                  core: 0.000 (numpy)
                  compat: 0.000 (numpy)
                  lib: 0.000 (numpy)
                  fft: 0.001 (numpy)
                  polyutils: 0.000 (numpy)
                  polytemplate: 0.000 (numpy)
                  chebyshev: 0.005 (numpy)
                  mtrand: 0.002 (numpy)
                  ctypeslib: 0.001 (numpy)
                   numpy.core._internal: 0.000 (ctypeslib)
                  ma: 0.005 (numpy)
                  matrixlib: 0.000 (numpy)
0.056 numpy (complex_plot)
0.035 add_newdocs (numpy)

I think this is because of the new complex_plot module, which I think I positively reviewed, so this is my fault. To resolve this ticket, make that import sufficiently lazy. Also, make a doctest that verifies that numpy is not imported when Sage starts up.

Attachments (1)

trac_6494.patch (5.9 KB) - added by Mike Hansen 12 years ago.

Download all attachments as: .zip

Change History (7)

Changed 12 years ago by Mike Hansen

Attachment: trac_6494.patch added

comment:1 Changed 12 years ago by Mike Hansen

Authors: Mike Hansen
Cc: William Stein added
Report Upstream: N/A
Status: newneeds_review

I don't think you can cimport numpy without causing an import in the module. Thus, a number of things have to be lazily imported. This will cause a problem if people do

sage: from import TimeSeries
sage: isinstance(foo, TimeSeries)

since TimeSeries? will be a LazyImport? object rather than a class. I'm not sure the best thing to do, but I've posted a patch anyway.

comment:2 Changed 12 years ago by Jason Grout

Cc: Jason Grout added

numpy recently has made great improvements in its import speed, so maybe this isn't quite the issue it used to be?

comment:3 Changed 12 years ago by Robert Bradshaw

Cc: Robert Bradshaw added

comment:4 Changed 11 years ago by Jeroen Demeyer

Description: modified (diff)
Status: needs_reviewneeds_work

I'm not going to judge whether numpy imports are still an issue or not, but in any case the patch needs to be rebased:

patching file sage/calculus/
Hunk #2 succeeded at 16 (offset 1 line).
patching file sage/finance/
patching file sage/interfaces/
patching file sage/plot/
Hunk #2 FAILED at 21.
1 out of 2 hunks FAILED -- saving rejects to file sage/plot/
patching file sage/plot/plot3d/
Hunk #2 succeeded at 255 (offset 10 lines).
patching file sage/stats/
patching file sage/stats/hmm/

comment:5 Changed 11 years ago by Mike Hansen

Milestone: sage-5.0sage-duplicate/invalid/wontfix
Resolution: invalid
Status: needs_workclosed

This ticket is invalid now as all of the changes appearing in it are already in the Sage library.

comment:6 Changed 11 years ago by Jeroen Demeyer

Authors: Mike Hansen
Reviewers: Mike Hansen

You shouldn't just close tickets, leave that to the release manager.

Note: See TracTickets for help on using tickets.