sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 478 forks source link

doctesting of sage/interfaces/r.py prints some warnings #31300

Closed DaveWitteMorris closed 2 years ago

DaveWitteMorris commented 3 years ago

As pointed out by gh-kliem in ticket #29967, doctesting the interface to R yields some warnings, even though all tests pass:

~/sage % ./sage -t src/sage/interfaces/r.py
Running doctests with ID 2021-01-28-19-03-19-0ac9e573.
Git branch: develop
Using --optional=build,dochtml,homebrew,pip,sage,sage_spkg
Doctesting 1 file.
R[write to console]: Warning messages:

R[write to console]: 1: 
R[write to console]: In sage10 + sage6 :
R[write to console]: 

R[write to console]:  longer object length is not a multiple of shorter object length

R[write to console]: 2: 
R[write to console]: In sqrt(sage10) :
R[write to console]:  NaNs produced

R[write to console]: 3: 
R[write to console]: In sqrt(sage4) :
R[write to console]:  NaNs produced

sage -t --warn-long 42.2 --random-seed=0 src/sage/interfaces/r.py
    [257 tests, 3.17 s]
----------------------------------------------------------------------
All tests passed!

Perhaps a user of R can say whether these warnings are revealing anything that needs to be fixed.

(These warnings were reported with --random-seed=151058820726654196682836430928254760259, but I get them even without specifying a seed.)

Component: interfaces

Keywords: R, statistics

Reviewer: Dave Morris

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

DaveWitteMorris commented 2 years ago

Reviewer: Dave Morris

DaveWitteMorris commented 2 years ago
comment:4

The warnings are expected, so there is no problem here, so this ticket should be closed as invalid.

1) The doctest is:

The following command generates a new vector `v` of length 11 constructed
by adding together (element by element) `2x` repeated 2.2 times, `y`
repeated just once, and 1 repeated 11 times::

    sage: v = 2*x+y+1; v  # optional - rpy2
    [1] 32.2 17.8 10.3 20.2 66.1 21.8 22.6 12.8 16.9 50.8 43.5

This is intentionally adding two vectors whose lengths are not multiples of each other: the length of 2*x is 5, and the length of y is 11.

2 and 3) The doctests are:

    sage: r(-17).sqrt()  # optional - rpy2
    [1] NaN

The conversion can handle "not a number", infintiy, imaginary values and
missing values:

    sage: r(-17).sqrt().sage()  # optional - rpy2
    nan

Both are intentionally creating a NaN value by taking the square root of a negative number.

Related ticket: #34134 (typo "infintiy" in docstring of r interface)