Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make doctests compatible with Macaulay2 1.17 #31773

Closed
mwageringel opened this issue May 3, 2021 · 15 comments
Closed

make doctests compatible with Macaulay2 1.17 #31773

mwageringel opened this issue May 3, 2021 · 15 comments

Comments

@mwageringel
Copy link

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

Component: interfaces

Keywords: macaulay2

Author: Markus Wageringel

Branch: 919907a

Reviewer: Samuel Lelièvre

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

@mwageringel mwageringel added this to the sage-9.4 milestone May 3, 2021
@mwageringel
Copy link
Author

Commit: 919907a

@mwageringel
Copy link
Author

Author: Markus Wageringel

@mwageringel
Copy link
Author

comment:1

This should be compatible with older versions as well.


New commits:

919907a31773: make doctests compatible with Macaulay2 1.17

@mwageringel
Copy link
Author

Branch: u/gh-mwageringel/31773

@sheerluck
Copy link
Contributor

comment:2

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 )

@mwageringel
Copy link
Author

comment:3

Replying to @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 " " -)

@mwageringel
Copy link
Author

Changed keywords from none to macaulay2

@slel
Copy link
Member

slel commented May 15, 2021

Reviewer: Samuel Lelièvre

@slel
Copy link
Member

slel commented May 15, 2021

comment:4

Good.

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

@sheerluck
Copy link
Contributor

comment:5

Replying to @slel:

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
  1. go there, open kernel.json, and after "language": "sage" add "env":
{
  ...
  "language": "sage",
  "env": {"PATH":"/home/sheerluck/M2/install/bin:$PATH"} 
}

@mkoeppe
Copy link
Member

mkoeppe commented Jul 24, 2021

comment:6

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

@vbraun
Copy link
Member

vbraun commented Jul 25, 2021

Changed branch from u/gh-mwageringel/31773 to 919907a

@murrayE
Copy link
Mannequin

murrayE mannequin commented Aug 29, 2022

Changed commit from 919907a to none

@murrayE
Copy link
Mannequin

murrayE mannequin commented Aug 29, 2022

comment:8

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?

@sheerluck
Copy link
Contributor

comment:9

Replying to @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"}
  1. that both paths are separated with colon: "PATH":"/opt/M2/bin/:/opt/octave/bin/:$PATH"

  2. that sage -n jupyter starts without errors

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

  4. that we get '/opt/M2/bin/M2' after

import shutil
shutil.which("M2")
  1. 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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants