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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh macaulay2 interface a little bit #36470

Merged
merged 3 commits into from
Oct 21, 2023

Conversation

fchapoton
Copy link
Contributor

  • changing the official link to macaulay2.com
  • gather some optional annotations
  • a few pep8 details fixed

馃摑 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.

@jhpalmieri
Copy link
Member

Looks okay to me and does some good cleanup. Before and after this branch I get the same doctest failures. This is on OS X with the homebrew installation of Macaulay2. For example with this branch:

% ./sage -t --optional=sage,macaulay2 src/sage/interfaces/macaulay2.py
too many failed tests, not using stored timings
Running doctests with ID 2023-10-16-13-36-01-a9a4de29.
Git branch: refresh_M2_interface
Git ref: 10.2.beta7-1-gcce709cc19e
Running with SAGE_LOCAL='/Users/palmieri/Sage/git/sage/local' and SAGE_VENV='/Users/palmieri/Sage/git/sage/local/var/lib/sage/venv-python3.11'
Using --optional=macaulay2,sage
Features to be detected: 4ti2,benzene,bliss,buckygen,conway_polynomials,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_jones_numfield,database_knotinfo,dvipng,fpylll,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,graphviz,imagemagick,ipython,jupymake,kenzo,latte_int,lrcalc_python,lrslib,mcqd,meataxe,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pynormaliz,pyparsing,python_igraph,requests,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,scipy,singular,sphinx,sympy,tdlib
Doctesting 1 file.
sage -t --random-seed=290974072611514737737072129485001771729 src/sage/interfaces/macaulay2.py
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 663, in sage.interfaces.macaulay2.Macaulay2.version
Failed example:
    macaulay2.version() # optional - macaulay2
Exception raised:
    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.Macaulay2.version[0]>", line 1, in <module>
        macaulay2.version() # optional - macaulay2
        ^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 668, in version
        s = r.search(s).groups()[0]
            ^^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'groups'
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 728, in sage.interfaces.macaulay2.Macaulay2.ring
Failed example:
    R1.describe()  # optional - macaulay2
Expected:
    ZZ
    --[a..d, Degrees => {4:1}, Heft => {1}, MonomialOrder => {MonomialSize => 16},
     7                                                       {GRevLex => {4:1}  }
                                                             {Position => Up    }
    --------------------------------------------------------------------------------
    DegreeRank => 1]
Got:
    ZZ
    --[a..d, Degrees => {4:1}, Heft => {1}, MonomialOrder => {MonomialSize => 16}]
     7                                                       {GRevLex => {4:1}  }
                                                             {Position => Up    }
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 741, in sage.interfaces.macaulay2.Macaulay2.ring
Failed example:
    R2.describe()  # optional - macaulay2
Expected:
    QQ[x..y, Degrees => {2:1}, Heft => {1}, MonomialOrder => {MonomialSize => 16},
                                                             {Lex => 2          }
                                                             {Position => Up    }
    --------------------------------------------------------------------------------
    DegreeRank => 1]
Got:
    QQ[x..y, Degrees => {2:1}, Heft => {1}, MonomialOrder => {MonomialSize => 16}]
                                                             {Lex => 2          }
                                                             {Position => Up    }
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 900, in sage.interfaces.macaulay2.Macaulay2Element._latex_
Failed example:
    latex(m) # optional - macaulay2
Expected:
    \left(\begin{smallmatrix} 1&2\\ 3&4\\ \end{smallmatrix}\right)
Got:
    \left(\!\begin{array}{cc} 1&2\\ 3&4 \end{array}\!\right)
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 985, in sage.interfaces.macaulay2.Macaulay2Element.external_string
Failed example:
    R.external_string()                      # optional - macaulay2
Expected:
    'QQ(monoid[x..y, Degrees => {2:1}, Heft => {1}, MonomialOrder => VerticalList{MonomialSize => 32, GRevLex => {2:1}, Position => Up}, DegreeRank => 1])'
Got:
    'QQ[x..y, Degrees => {2:1}, Heft => {1}]'
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 1524, in sage.interfaces.macaulay2.Macaulay2Element._sage_
Failed example:
    g.sage()
Exception raised:
    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1496, in __init__
        self._name = parent._create(value, name=name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 516, in _create
        self.set(name, value)
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 457, in set
        raise RuntimeError("Error evaluating Macaulay2 code.\nIN:%s\nOUT:%s" % (cmd, ans))
    RuntimeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage16,(vertices(sage19,sort=sage25)));
    OUT:stdio:1868:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.Macaulay2Element._sage_[40]>", line 1, in <module>
        g.sage()
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 1121, in sage
        return self._sage_(*args, **kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 1676, in _sage_
        g.relabel(self.vertices(sort=True))
                  ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 696, in __call__
        return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 616, in function_call
        return self.new(s)
               ^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 385, in new
        return self(code)
               ^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 298, in __call__
        return cls(self, x, name=name)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1501, in __init__
        raise TypeError(*x.args)
    TypeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage16,(vertices(sage19,sort=sage25)));
    OUT:stdio:1868:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 1526, in sage.interfaces.macaulay2.Macaulay2Element._sage_
Failed example:
    g.sage().edges(labels=False)
Exception raised:
    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1496, in __init__
        self._name = parent._create(value, name=name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 516, in _create
        self.set(name, value)
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 457, in set
        raise RuntimeError("Error evaluating Macaulay2 code.\nIN:%s\nOUT:%s" % (cmd, ans))
    RuntimeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage18,(vertices(sage19,sort=sage26)));
    OUT:stdio:2247:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.Macaulay2Element._sage_[41]>", line 1, in <module>
        g.sage().edges(labels=False)
        ^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 1121, in sage
        return self._sage_(*args, **kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 1676, in _sage_
        g.relabel(self.vertices(sort=True))
                  ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 696, in __call__
        return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 616, in function_call
        return self.new(s)
               ^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 385, in new
        return self(code)
               ^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 298, in __call__
        return cls(self, x, name=name)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1501, in __init__
        raise TypeError(*x.args)
    TypeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage18,(vertices(sage19,sort=sage26)));
    OUT:stdio:2247:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 1532, in sage.interfaces.macaulay2.Macaulay2Element._sage_
Failed example:
    g.sage()
Exception raised:
    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1496, in __init__
        self._name = parent._create(value, name=name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 516, in _create
        self.set(name, value)
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 457, in set
        raise RuntimeError("Error evaluating Macaulay2 code.\nIN:%s\nOUT:%s" % (cmd, ans))
    RuntimeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage25,(vertices(sage27,sort=sage28)));
    OUT:stdio:2381:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.Macaulay2Element._sage_[44]>", line 1, in <module>
        g.sage()
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 1121, in sage
        return self._sage_(*args, **kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 1676, in _sage_
        g.relabel(self.vertices(sort=True))
                  ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 696, in __call__
        return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 616, in function_call
        return self.new(s)
               ^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 385, in new
        return self(code)
               ^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 298, in __call__
        return cls(self, x, name=name)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1501, in __init__
        raise TypeError(*x.args)
    TypeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage25,(vertices(sage27,sort=sage28)));
    OUT:stdio:2381:47:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 1534, in sage.interfaces.macaulay2.Macaulay2Element._sage_
Failed example:
    g.sage().edges(labels=False)
Exception raised:
    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1496, in __init__
        self._name = parent._create(value, name=name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 516, in _create
        self.set(name, value)
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 457, in set
        raise RuntimeError("Error evaluating Macaulay2 code.\nIN:%s\nOUT:%s" % (cmd, ans))
    RuntimeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage9,(vertices(sage27,sort=sage29)));
    OUT:stdio:2514:46:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.Macaulay2Element._sage_[45]>", line 1, in <module>
        g.sage().edges(labels=False)
        ^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 1121, in sage
        return self._sage_(*args, **kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 1676, in _sage_
        g.relabel(self.vertices(sort=True))
                  ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 696, in __call__
        return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 616, in function_call
        return self.new(s)
               ^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 385, in new
        return self(code)
               ^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/interface.py", line 298, in __call__
        return cls(self, x, name=name)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/expect.py", line 1501, in __init__
        raise TypeError(*x.args)
    TypeError: Error evaluating Macaulay2 code.
    IN:sageAssign(symbol sage9,(vertices(sage27,sort=sage29)));
    OUT:stdio:2514:46:(3): error: assignment to protected global variable 'sort', originally defined at /usr/local/share/Macaulay2/Core/classes.m2:105:35:(1):
**********************************************************************
File "src/sage/interfaces/macaulay2.py", line 1886, in sage.interfaces.macaulay2.is_Macaulay2Element
Failed example:
    is_Macaulay2Element(2)              # optional - macaulay2
Expected:
    doctest:...: DeprecationWarning: the function is_Macaulay2Element is deprecated; use isinstance(x, sage.interfaces.abc.MacaulayElement) instead
    See https://github.com/sagemath/sage/issues/34823 for details.
    False
Got:
    doctest:warning
      File "/Users/palmieri/Sage/git/sage/src/bin/sage-runtests", line 162, in <module>
        err = DC.run()
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/control.py", line 1535, in run
        self.run_doctests()
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/control.py", line 1147, in run_doctests
        self.dispatcher.dispatch()
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 2085, in dispatch
        self.parallel_dispatch()
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1980, in parallel_dispatch
        w.start()  # This might take some time
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 2254, in start
        super().start()
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 121, in start
        self._popen = self._Popen(self)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
        return Popen(process_obj)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
        self._launch(process_obj)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
        code = process_obj._bootstrap(parent_sentinel=child_r)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
        self.run()
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 2226, in run
        task(self.options, self.outtmpfile, msgpipe, self.result_queue)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 2556, in __call__
        doctests, extras = self._run(runner, options, results)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 2608, in _run
        result = runner.run(test)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 908, in run
        return self._run(test, compileflags, out)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/palmieri/Sage/git/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.macaulay2.is_Macaulay2Element[1]>", line 1, in <module>
        is_Macaulay2Element(Integer(2))              # optional - macaulay2
      File "/Users/palmieri/Sage/git/sage/src/sage/interfaces/macaulay2.py", line 1894, in is_Macaulay2Element
        deprecation(34804, "the function is_Macaulay2Element is deprecated; use isinstance(x, sage.interfaces.abc.Macaulay2Element) instead")
      File "/Users/palmieri/Sage/git/sage/src/sage/misc/superseded.py", line 98, in deprecation
        warning(issue_number, message, DeprecationWarning, stacklevel)
      File "/Users/palmieri/Sage/git/sage/src/sage/misc/superseded.py", line 177, in warning
        warn(message, warning_class, stacklevel)
      File "/usr/local/Cellar/python@3.11/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/warnings.py", line 109, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    DeprecationWarning: the function is_Macaulay2Element is deprecated; use isinstance(x, sage.interfaces.abc.Macaulay2Element) instead
    See https://github.com/sagemath/sage/issues/34804 for details.
    False
**********************************************************************
6 items had failures:
   2 of   7 in sage.interfaces.macaulay2.Macaulay2.ring
   1 of   2 in sage.interfaces.macaulay2.Macaulay2.version
   1 of   4 in sage.interfaces.macaulay2.Macaulay2Element._latex_
   4 of  62 in sage.interfaces.macaulay2.Macaulay2Element._sage_
   1 of   3 in sage.interfaces.macaulay2.Macaulay2Element.external_string
   1 of   4 in sage.interfaces.macaulay2.is_Macaulay2Element
    [296 tests, 10 failures, 13.49 s]
----------------------------------------------------------------------
sage -t --random-seed=290974072611514737737072129485001771729 src/sage/interfaces/macaulay2.py  # 10 doctests failed
----------------------------------------------------------------------
Total time for all tests: 14.0 seconds
    cpu time: 2.5 seconds
    cumulative wall time: 13.5 seconds
Features detected for doctesting: 
pytest is not installed in the venv, skip checking tests that rely on it

Is there a ticket to fix these?

@jhpalmieri
Copy link
Member

I don't know how to fix the problems with _sage_, but the others seem not so hard. For example, the version problem:

diff --git a/src/sage/interfaces/macaulay2.py b/src/sage/interfaces/macaulay2.py
index 1fd27a72bb3..b21dbd47910 100644
--- a/src/sage/interfaces/macaulay2.py
+++ b/src/sage/interfaces/macaulay2.py
@@ -656,16 +656,14 @@ class Macaulay2(ExtraTabCompletion, Expect):
 
     def version(self):
         """
-        Returns the version of Macaulay2.
+        Returns the version of Macaulay2 as a tuple: (major, minor)
 
         EXAMPLES::
 
             sage: macaulay2.version() # optional - macaulay2
-            (1, 1...
+            (1, ...)
         """
-        s = self.eval("version")
-        r = re.compile("VERSION => (.*?)\n")
-        s = r.search(s).groups()[0]
+        s = self.eval('version#"VERSION"')
         return tuple(int(i) for i in s.split("."))
 
     # Constructors

@fchapoton
Copy link
Contributor Author

I have fixed some of them. Now doctests pass for me with macaualay2 1.19.1 from ubuntu

@fchapoton
Copy link
Contributor Author

fchapoton commented Oct 17, 2023

I have also used your suggestion for a better version method.

@fchapoton
Copy link
Contributor Author

The other failures seem to depend on M2 version in use. Yours is the latest 1.22 maybe ?

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@jhpalmieri
Copy link
Member

The other failures seem to depend on M2 version in use. Yours is the latest 1.22 maybe ?

Yes, 1.22.

@jhpalmieri
Copy link
Member

Thank you for the fixes!

@vbraun vbraun merged commit ad4546c into sagemath:develop Oct 21, 2023
33 of 52 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Oct 21, 2023
@fchapoton fchapoton deleted the refresh_M2_interface branch October 24, 2023 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants