Opened 21 months ago

Closed 19 months ago

Last modified 5 months ago

#31773 closed defect (fixed)

make doctests compatible with Macaulay2 1.17

Reported by: gh-mwageringel Owned by:
Priority: major Milestone: sage-9.4
Component: interfaces Keywords: macaulay2
Cc: Merged in:
Authors: Markus Wageringel Reviewers: Samuel Lelièvre
Report Upstream: N/A Work issues:
Branch: 919907a (Commits, GitHub, GitLab) Commit:
Dependencies: Stopgaps:

Status badges

Description

With Macaulay2 1.17, some doctests fail due to slight changes in the print representation.

Change History (9)

comment:1 Changed 21 months ago by gh-mwageringel

Authors: Markus Wageringel
Branch: u/gh-mwageringel/31773
Commit: 919907a7f038103beeb38bb1478d0f3ec98984ed
Status: newneeds_review

This should be compatible with older versions as well.


New commits:

919907a31773: make doctests compatible with Macaulay2 1.17

comment:2 Changed 21 months ago by gh-sheerluck

I tried Macaulay2, version 1.17.2.1, from master branch.

Every [x...z] in 1.17 changed to [x..z] in 1.17.2.1

Example:

sage: str(macaulay2("QQ[x,y,z]/(x+y+z)"))
 QQ[x..z]
---------
x + y + z

sage: R.<x,y,z,w> = PolynomialRing(ZZ, 4)
sage: I = R.ideal([x*y-z^2, y^2-w^2])
sage: Q = R.quotient(I)
sage: Q._macaulay2_init_()
    ZZ[x..z, w]
-------------------
        2   2    2
(x*y - z , y  - w )

comment:3 in reply to:  2 Changed 21 months ago by gh-mwageringel

Keywords: macaulay2 added

Replying to gh-sheerluck:

I tried Macaulay2, version 1.17.2.1, from master branch.

Every [x...z] in 1.17 changed to [x..z] in 1.17.2.1

Yes, it is [x..z] on my end, too. I have used triple dots ... because they are interpreted as a generic placeholder by our doctesting framework. This way, the tests also pass with older versions of Macaulay2, as [x...z] also matches [x, y, z].

You can try to run the tests on the few files that contain Macaulay2 doctests like this:

./sage -t -l --optional=sage,macaulay2 $(git grep -l -i "optional.*macaulay2" | paste -sd " " -)

comment:4 Changed 21 months ago by slelievre

Reviewers: Samuel Lelièvre
Status: needs_reviewpositive_review

Good.

By the way do you know how to use the M2 interface in Jupyter? Someone is asking at

comment:5 in reply to:  4 Changed 21 months ago by gh-sheerluck

Replying to slelievre:

By the way do you know how to use the M2 interface in Jupyter?

test if M2 is found

In [1]: import shutil
         shutil.which("M2")
Out[1]:
'/home/sheerluck/M2/install/bin/M2'

if shutil.which returns empty string, we need to add PATH to kernel:

1) jupyter-kernelspec list shows where sagemath kernel is

$ jupyter-kernelspec list
Available kernels:
...
sagemath          /usr/share/jupyter/kernels/sagemath

2) go there, open kernel.json, and after "language": "sage" add "env":

{
  ...
  "language": "sage",
  "env": {"PATH":"/home/sheerluck/M2/install/bin:$PATH"} 
}

comment:6 Changed 19 months ago by mkoeppe

Priority: minormajor

Promoting 5 tickets that fix defects to "major" so that they have a chance to get merged

comment:7 Changed 19 months ago by vbraun

Branch: u/gh-mwageringel/31773919907a7f038103beeb38bb1478d0f3ec98984ed
Resolution: fixed
Status: positive_reviewclosed

comment:8 Changed 5 months ago by gh-murrayE

Commit: 919907a7f038103beeb38bb1478d0f3ec98984ed

Reply to gh-sheerluck: such addition to kernel.json to include paths to octave and Macaulay2's M2 does not allow me to use either octave or the macaulay2 from a jupyter notebook opened from SageMath-9.6 arm64 version under macOS 12.5.1 on an M1 Mac. What's wrong?

comment:9 in reply to:  8 Changed 5 months ago by gh-sheerluck

Replying to gh-murrayE:

What's wrong?

we need to check several things

1) that M2 and octave work with full paths. If on some system M2 is installed in /opt/M2 and octave is installed in /opt/octave we need to check that /opt/M2/bin/M2 works and /opt/octave/bin/octave-cli works. M2 can fail to run with "/usr/lib64/libfactory-4.3.0.so not found" if singular was recently updated to 4.3.1

2) that before "env": {"PATH":"/opt/M2/bin/:/opt/octave/bin/:$PATH"} line there is a comma after "language": "sage":

 "display_name": "SageMath 9.7.beta8",
 "language": "sage",
 "env": {"PATH":"/opt/M2/bin/:/opt/octave/bin/:$PATH"}

3) that both paths are separated with colon: "PATH":"/opt/M2/bin/:/opt/octave/bin/:$PATH"

4) that sage -n jupyter starts without errors

5) that "display_name" from 2) is what we see in jupyter

6) that we get '/opt/M2/bin/M2' after

import shutil
shutil.which("M2")

7) that we get '/opt/octave/bin/octave-cli' after

import shutil
shutil.which("octave-cli")

If all that is checked, jupyter has to give us something like

In [1]: macaulay2("2+2")

Out[1]: 4

In [2]: octave.eval('2+2')

Out[2]: 'ans = 4'
Note: See TracTickets for help on using tickets.