Opened 2 years ago

Closed 2 years ago

Last modified 20 months ago

#29115 closed enhancement (fixed)

Fix deprecation warnings with scipy 1.4

Reported by: arojas Owned by:
Priority: major Milestone: sage-9.1
Component: packages: standard Keywords:
Cc: fbissey, gh-timokau, isuruf Merged in:
Authors: Antonio Rojas Reviewers: François Bissey
Report Upstream: N/A Work issues:
Branch: a676e5a (Commits, GitHub, GitLab) Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by arojas)

scipy 1.4 causes some test failures due to deprecation warnings. Some of them arise from networkx code (already fixed upstream), here we fix the ones that come from sage code

Change History (17)

comment:1 Changed 2 years ago by arojas

  • Branch set to u/arojas/fix_deprecation_warnings_with_scipy_1_4

comment:2 Changed 2 years ago by git

  • Commit set to 83f886c21d06485b806f7b3f5f3cc9487849a2ac

Branch pushed to git repo; I updated commit sha1. New commits:

83f886cPort away from deprecated scipy API

comment:3 Changed 2 years ago by arojas

  • Authors set to Antonio Rojas
  • Component changed from PLEASE CHANGE to packages: standard
  • Description modified (diff)
  • Reviewers set to fbissey, gh-timokau, isuruf
  • Status changed from new to needs_review
  • Type changed from PLEASE CHANGE to enhancement

comment:4 Changed 2 years ago by fbissey

I was just going to look at scipy 1.4 (in fact I have doctest run going on).

Note that setting the reviewers field doesn't actually cc people.

comment:5 Changed 2 years ago by arojas

  • Cc fbissey gh-timokau isuruf added
  • Reviewers fbissey, gh-timokau, isuruf deleted

oops

comment:6 follow-up: Changed 2 years ago by fbissey

You are talking about networkx, is it safe and better to move to a newer version in your experience? I have 2.4 available in my tree. We'll have to look at matplotlib as well - considering the last two upgrades that may not be fun.

Last edited 2 years ago by fbissey (previous) (diff)

comment:7 in reply to: ↑ 6 Changed 2 years ago by arojas

Replying to fbissey:

You are talking about networkx, is it safe and better to move to a newer version in your experience? I have 2.4 available in my tree. We'll have to look at matplotlib as well - considering the last two upgrades that may not be fun.

The deprecation warning fixes in networkx and in this ticket are orthogonal - both need to be applied eventually. The networkx fix is not yet in any stable release and the patch is huge and doesn't apply over the latest release [1] - I don't think it's worth the effort of trying to rebase it.

The upgrade to networkx 2.4 it pretty straightforward - there is just one test failure (caused by an expected deprecation warning that no longer happens, ironically). The matplotlib upgrade is also quite painless - there are just a couple of minor test failures related to pixel metric changes, one of which is an issue already with the current version (just not detected by doctests, cf. #28449)

All of these upgrades are python3-only, so I guess they need to wait for the outcome of the python2-support-in-9.1 discussion.

[1] https://github.com/networkx/networkx/commit/ea19baaff252468f5a911260430e057393d9637d

comment:8 Changed 2 years ago by fbissey

Sounds good to know overall. I was very worried about matplotlib, I did the last two major upgrades in sage and neither was what I would call painless. I have been taking a bit of a step back for a while, it's good to know you are still very active.

comment:9 follow-up: Changed 2 years ago by fbissey

OK the networkx stuff in graphs/generic_graph.py is real ugly.

But I think we should be able to fix this one in this ticket

sage -t --long /usr/share/doc/sage-9999/html/en/thematic_tutorials/_sources/numerical_sage/scipy.rst
**********************************************************************
File "/usr/share/doc/sage-9999/html/en/thematic_tutorials/_sources/numerical_sage/scipy.rst", line 98, in scipy
Failed example:
    x= scipy.arange(0,100,.1)
Expected nothing
Got:
    doctest:warning
      File "/usr/lib/python-exec/python3.7/sage-runtests", line 179, in <module>
        err = DC.run()
      File "/usr/lib/python3.7/site-packages/sage/doctest/control.py", line 1228, in run
        self.run_doctests()
      File "/usr/lib/python3.7/site-packages/sage/doctest/control.py", line 929, in run_doctests
        self.dispatcher.dispatch()
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 2033, in dispatch
        self.parallel_dispatch()
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 1925, in parallel_dispatch
        w.start()  # This might take some time
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 2200, in start
        super(DocTestWorker, self).start()
      File "/usr/lib/python3.7/multiprocessing/process.py", line 112, in start
        self._popen = self._Popen(self)
      File "/usr/lib/python3.7/multiprocessing/context.py", line 223, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/usr/lib/python3.7/multiprocessing/context.py", line 277, in _Popen
        return Popen(process_obj)
      File "/usr/lib/python3.7/multiprocessing/popen_fork.py", line 20, in __init__
        self._launch(process_obj)
      File "/usr/lib/python3.7/multiprocessing/popen_fork.py", line 74, in _launch
        code = process_obj._bootstrap()
      File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
        self.run()
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 2172, in run
        task(self.options, self.outtmpfile, msgpipe, self.result_queue)
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 2504, in __call__
        doctests, extras = self._run(runner, options, results)
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 2553, in _run
        result = runner.run(test)
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 897, in run
        return self._run(test, compileflags, out)
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/lib/python3.7/site-packages/sage/doctest/forker.py", line 1123, in compile_and_execute
        exec(compiled, globs)
      File "<doctest scipy[4]>", line 1, in <module>
        x= scipy.arange(Integer(0),Integer(100),RealNumber('.1'))
      File "/usr/lib/python3.7/site-packages/scipy/_lib/deprecation.py", line 19, in call
        stacklevel=stacklevel)
      File "/usr/lib/python3.7/warnings.py", line 110, in _showwarnmsg
        msg.file, msg.line)
    :
    DeprecationWarning: scipy.arange is deprecated and will be removed in SciPy 2.0.0, use numpy.arange instead
**********************************************************************
1 item had failures:
   1 of  14 in scipy
    [11 tests, 1 failure, 1.11 s]

It is part of a code block

    sage: import scipy
    sage: from scipy import integrate
    sage: def f_1(y,t):
    ....:    return[y[1],-y[0]-10*y[1]*(y[0]**2-1)]
    sage: def j_1(y,t):
    ....:    return [ [0, 1.0],[-2.0*10*y[0]*y[1]-1.0,-10*(y[0]*y[0]-1.0)] ]
    sage: x= scipy.arange(0,100,.1)
    sage: y=integrate.odeint(f_1,[1,0],x,Dfun=j_1)

I think it is totally fine to add an import of numpy and do the suggested replacement.

comment:10 Changed 2 years ago by git

  • Commit changed from 83f886c21d06485b806f7b3f5f3cc9487849a2ac to cc7988dfcfc612e853a31cf1cf471371ef6f08e8

Branch pushed to git repo; I updated commit sha1. New commits:

cc7988dAlso fix test in documentation

comment:11 in reply to: ↑ 9 ; follow-up: Changed 2 years ago by arojas

Replying to fbissey:

OK the networkx stuff in graphs/generic_graph.py is real ugly.

But I think we should be able to fix this one in this ticket

Thanks, I always forget that there are tests in the docs too (those get installed with a .txt suffix for some reason so they are not picked up by the tester by default)

comment:12 Changed 2 years ago by git

  • Commit changed from cc7988dfcfc612e853a31cf1cf471371ef6f08e8 to a676e5adafb578aa40170aa38eaa0d33ac9b0b8a

Branch pushed to git repo; I updated commit sha1. New commits:

a676e5aRemove unnecessary import

comment:13 in reply to: ↑ 11 Changed 2 years ago by fbissey

Replying to arojas:

Replying to fbissey:

OK the networkx stuff in graphs/generic_graph.py is real ugly.

But I think we should be able to fix this one in this ticket

Thanks, I always forget that there are tests in the docs too (those get installed with a .txt suffix for some reason so they are not picked up by the tester by default)

Yes that's one issue that started noticing at least a couple of years ago. I have a section in my install script to deal with all sort of unwanted results. I am not particularly sophisticated about that one

		# restore .rst.txt file to .rst
		for i in `find build_doc -name \*.rst.txt`; do
			mv "${i}" "${i%.txt}"
		done

but now I am testing them too.

comment:14 Changed 2 years ago by fbissey

  • Reviewers set to François Bissey
  • Status changed from needs_review to positive_review

comment:15 Changed 2 years ago by vbraun

  • Branch changed from u/arojas/fix_deprecation_warnings_with_scipy_1_4 to a676e5adafb578aa40170aa38eaa0d33ac9b0b8a
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:16 Changed 20 months ago by dimpase

  • Commit a676e5adafb578aa40170aa38eaa0d33ac9b0b8a deleted

networkx warnings are fixed in their trunk, but not in the latest release (2.4).

comment:17 Changed 20 months ago by dimpase

see also #29766

Note: See TracTickets for help on using tickets.