deprecation warning about "`\QQ`" and "\*"

53 views
Skip to first unread message

rana-aere

unread,
Mar 28, 2020, 10:07:53 AM3/28/20
to sage-support


I am compiling binary-pkg and encountered a deprecation warning.
The warning appeared when I invoked sage from command line.
(Technically, it was after messages of patching.)

The warning reads

```
.../quotient_ring.py:1350: DeprecationWarning: invalid escape sequence \Q
```


The description (line 1300--1350) of _macaulay2_init contains a line

```
Quotients of multivariate polynomial rings over `\QQ`, `\ZZ` and
```

So, I inserted 'r' before """ on line 1300. (""" -> r""").

After reinvocation of sage, the previous warning is gone.
Unfortunately, I cannot test the effect of the change on description.
I tried typing "_macaulay2_init_?". This did not work.

How can I test it? (Question 1.)

I thought  function name with "?" might not be the right syntax.
So, I tested "sqrt?". It gave me a series of deprecation warnings like

```
.../sessions.py:565: DeprecationWarning: invalid escape sequence \*
```

They make the screen to scroll one page.

These warnings for sessions.py are also descriptions of functions enclosed by """...""" pair inserted of r"""...""".
Yes, the recommended style was r"""..."" for description containing latex expressions.
The warnings for sessions.py might be regular expressions intended to be displayed by "function_name?"
or may be "*" are really escaped so that enclosing by r"""...""" and changing "\*" with "*" might help.
I do not have knowledge to distinguish these two.

(Question 2.) Is there any body who can tell which correction is suitable for sessions.py?
Option 1. """...""" -> r"""..."""
Option ". """... \*...""" -> r"""... *..."""

John H Palmieri

unread,
Mar 28, 2020, 12:30:01 PM3/28/20
to sage-support


On Saturday, March 28, 2020 at 7:07:53 AM UTC-7, rana-aere wrote:


I am compiling binary-pkg and encountered a deprecation warning.
The warning appeared when I invoked sage from command line.
(Technically, it was after messages of patching.)

The warning reads

```
.../quotient_ring.py:1350: DeprecationWarning: invalid escape sequence \Q
```

I read the file quotient_ring.py located at SageMath-9.1.beta8.app/Contents/Resources/sage/local/lib/python3.7/site-packages/sage/rings.

The description (line 1300--1350) of _macaulay2_init contains a line

```
Quotients of multivariate polynomial rings over `\QQ`, `\ZZ` and
```

So, I inserted 'r' before """ on line 1300. (""" -> r""").

After reinvocation of sage, the previous warning is gone.
Unfortunately, I cannot test the effect of the change on description.
I tried typing "_macaulay2_init_?". This did not work.

It's a method, not a function. You have to call it on an appropriate object.

R.<x,y> = PolynomialRing(QQ)
I = R.ideal([x^2-y])
S = R.quotient_ring(I)
S._macaulay2_init_?

 

How can I test it? (Question 1.)

Adding the "r" is certainly the right thing to do.
 

I thought  function name with "?" might not be the right syntax.
So, I tested "sqrt?". It gave me a series of deprecation warnings like

```
.../sessions.py:565: DeprecationWarning: invalid escape sequence \*
```

They make the screen to scroll one page.

These warnings for sessions.py are also descriptions of functions enclosed by """...""" pair inserted of r"""...""".
Yes, the recommended style was r"""..."" for description containing latex expressions.
The warnings for sessions.py might be regular expressions intended to be displayed by "function_name?"
or may be "*" are really escaped so that enclosing by r"""...""" and changing "\*" with "*" might help.
I do not have knowledge to distinguish these two.

(Question 2.) Is there any body who can tell which correction is suitable for sessions.py?
Option 1. """...""" -> r"""..."""
Option ". """... \*...""" -> r"""... *..."""

There is no file "sessions.py" in the Sage library. This may be referring to a file in some package like "requests", but that's not a file that the Sage developers control. Once you identify which package the file comes from, talk to its developers about what to do.

rana-aere

unread,
Mar 29, 2020, 3:24:38 AM3/29/20
to sage-support
Thank you for clear instructions.
I used the codes to compare how doctoring of the method _macaulay2_init_ is displayed. 

sage-8.9 (command line and jupyter)

```
Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature
Type:           builtin_function_or_method
```

sage-9.0 (command line and jupyter )

```
Signature:      S._macaulay2_init_(macaulay2=None)
Docstring:     
   EXAMPLES:

   Quotients of multivariate polynomial rings over QQ, ZZ and a
   finite field:
```

sage-9.1 (command line and jupyter)

```
Signature:      S._macaulay2_init_(macaulay2=None)
Docstring:     
   EXAMPLES:

   Quotients of multivariate polynomial rings over \QQ, \ZZ and a
   finite field:
```

All three have different behaviors.

I think true and meaningful difference should be observed in conversion to tutorial, wiki or manual....
If someone knows how to test it, please tell me the result.
I will find a way to make a ticket for it.

For now I proceed to check issues on "sqrt?"

John H Palmieri

unread,
Mar 29, 2020, 2:15:41 PM3/29/20
to sage-support
On Sunday, March 29, 2020 at 12:24:38 AM UTC-7, rana-aere wrote:
Thank you for clear instructions.
I used the codes to compare how doctoring of the method _macaulay2_init_ is displayed. 

sage-8.9 (command line and jupyter)

```
Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature
File:           /Applications/SageMath-8.9.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/structure/sage_object.pyx
Type:           builtin_function_or_method
```

sage-9.0 (command line and jupyter )

```
Signature:      S._macaulay2_init_(macaulay2=None)
Docstring:     
   EXAMPLES:

   Quotients of multivariate polynomial rings over QQ, ZZ and a
   finite field:
```

sage-9.1 (command line and jupyter)

```
Signature:      S._macaulay2_init_(macaulay2=None)
Docstring:     
   EXAMPLES:

   Quotients of multivariate polynomial rings over \QQ, \ZZ and a
   finite field:
```

All three have different behaviors.

The difference between Sage 8.9 and 9.0 is probably due to the switch from Python 2 to Python 3.
 

I think true and meaningful difference should be observed in conversion to tutorial, wiki or manual....

I don't consider these differences meaningful. What are you concerned about?
 
If someone knows how to test it, please tell me the result.

Test what, exactly?

rana-aere

unread,
Mar 30, 2020, 4:29:48 AM3/30/20
to sage-support
I just began learning development of Sagemath.
And reference manual of Sagemath looks like combination of original documentation
and collection of documentation from source code.
I do not know how modification of source influence the entire system, which include reference manuals.

I have a tendency to run into bugs other programmers/researchers do not encounter.
This means I will report many bugs.
So, I should learn to propose how to fix the bugs.

On the other hand,  my major was software engineering.
So, it is more creative for me to consider the whole system when I propose fixing bugs.

This is why I asked how I can test the influence of rewriting docstring.
Reply all
Reply to author
Forward
0 new messages