ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 04 Jul 2020 19:02:45 -0500Deprecation warning not showing for .sage scripthttps://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/Hello, Sage Community!
With Sage 9.1, if I write `text('$\int$', (0,0))`, I get the following deprecation warning:
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-2-75ff93257356>:1: DeprecationWarning: invalid escape sequence \i
text('$\int$', (Integer(0),Integer(0)))
Of course, the solution is to use raw strings: `text(r'$\int$', (0,0))`.
However, if I move that same command to a .sage script--let's call it `deprecation.sage`---, and I call `sage deprecation.sage`, I don't see any warning.
Previously, I had written a whole set of Sage and LaTeX commands for writing books and articles with Sage automatic calculations. These commands should check that the code is correct and no warning is issued by Sage. My problem here is that the commands do show every other types of warning, except for this one.
My question is: **Is there a way to activate deprecation warnings when executing .sage scripts?**
Thanks in advance for your answers!Wed, 01 Jul 2020 11:41:54 -0500https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/Comment by dsejas for <p>Hello, Sage Community!</p>
<p>With Sage 9.1, if I write <code>text('$\int$', (0,0))</code>, I get the following deprecation warning:</p>
<pre><code><input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-2-75ff93257356>:1: DeprecationWarning: invalid escape sequence \i
text('$\int$', (Integer(0),Integer(0)))
</code></pre>
<p>Of course, the solution is to use raw strings: <code>text(r'$\int$', (0,0))</code>.</p>
<p>However, if I move that same command to a .sage script--let's call it <code>deprecation.sage</code>---, and I call <code>sage deprecation.sage</code>, I don't see any warning.</p>
<p>Previously, I had written a whole set of Sage and LaTeX commands for writing books and articles with Sage automatic calculations. These commands should check that the code is correct and no warning is issued by Sage. My problem here is that the commands do show every other types of warning, except for this one.</p>
<p>My question is: <strong>Is there a way to activate deprecation warnings when executing .sage scripts?</strong></p>
<p>Thanks in advance for your answers!</p>
https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52293#post-id-52293Hello, @John Palmieri! Yes, my question is very broad because I require a very broad approach: I need my Sage and LaTeX commands/environments to catch **every** single warning issued by Sage or Python, when executing a .sage script.
Specifically, my Sage/LaTeX commands/environments create a global .sage file for a .tex document with the extracted code, much like sageTeX does. Then I need to execute that script, and I need it to print every single warning message issued in the process.
The objective of these commands and environments is to keep the embedded code up-to-date and clean. So, deprecation warnings (or any other kind of warning) being ignored is not a point in favor.Wed, 01 Jul 2020 16:36:55 -0500https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52293#post-id-52293Comment by John Palmieri for <p>Hello, Sage Community!</p>
<p>With Sage 9.1, if I write <code>text('$\int$', (0,0))</code>, I get the following deprecation warning:</p>
<pre><code><input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-2-75ff93257356>:1: DeprecationWarning: invalid escape sequence \i
text('$\int$', (Integer(0),Integer(0)))
</code></pre>
<p>Of course, the solution is to use raw strings: <code>text(r'$\int$', (0,0))</code>.</p>
<p>However, if I move that same command to a .sage script--let's call it <code>deprecation.sage</code>---, and I call <code>sage deprecation.sage</code>, I don't see any warning.</p>
<p>Previously, I had written a whole set of Sage and LaTeX commands for writing books and articles with Sage automatic calculations. These commands should check that the code is correct and no warning is issued by Sage. My problem here is that the commands do show every other types of warning, except for this one.</p>
<p>My question is: <strong>Is there a way to activate deprecation warnings when executing .sage scripts?</strong></p>
<p>Thanks in advance for your answers!</p>
https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52288#post-id-52288Your question is too broad: some deprecation warnings are printed when executing .sage scripts. For example: `P = Permutations(4); x = P([3,4,2,1]); x.has_left_descent(2, mult='l2r')`. The question is, why isn't this one printing? I don't actually see it when I run plain Python, although it seems to be a plain Python deprecation warning.Wed, 01 Jul 2020 13:56:40 -0500https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52288#post-id-52288Answer by John Palmieri for <p>Hello, Sage Community!</p>
<p>With Sage 9.1, if I write <code>text('$\int$', (0,0))</code>, I get the following deprecation warning:</p>
<pre><code><input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<input>:1: DeprecationWarning: invalid escape sequence \i
<ipython-input-2-75ff93257356>:1: DeprecationWarning: invalid escape sequence \i
text('$\int$', (Integer(0),Integer(0)))
</code></pre>
<p>Of course, the solution is to use raw strings: <code>text(r'$\int$', (0,0))</code>.</p>
<p>However, if I move that same command to a .sage script--let's call it <code>deprecation.sage</code>---, and I call <code>sage deprecation.sage</code>, I don't see any warning.</p>
<p>Previously, I had written a whole set of Sage and LaTeX commands for writing books and articles with Sage automatic calculations. These commands should check that the code is correct and no warning is issued by Sage. My problem here is that the commands do show every other types of warning, except for this one.</p>
<p>My question is: <strong>Is there a way to activate deprecation warnings when executing .sage scripts?</strong></p>
<p>Thanks in advance for your answers!</p>
https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?answer=52295#post-id-52295This is apparently a Python issue, not a Sage issue. Try
PYTHONWARNINGS=always sage deprecation.sage
from a shell prompt. See https://docs.python.org/3/library/warnings.html#default-warning-filter, also.Wed, 01 Jul 2020 18:38:01 -0500https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?answer=52295#post-id-52295Comment by dsejas for <p>This is apparently a Python issue, not a Sage issue. Try</p>
<pre><code>PYTHONWARNINGS=always sage deprecation.sage
</code></pre>
<p>from a shell prompt. See <a href="https://docs.python.org/3/library/warnings.html#default-warning-filter">https://docs.python.org/3/library/war...</a>, also.</p>
https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52330#post-id-52330This worked perfectly! Thank you very much!Sat, 04 Jul 2020 19:02:45 -0500https://ask.sagemath.org/question/52286/deprecation-warning-not-showing-for-sage-script/?comment=52330#post-id-52330