Opened 3 years ago

Closed 3 years ago

#28303 closed enhancement (fixed)

better string representation of Macaulay2 elements

Reported by: Markus Wageringel Owned by:
Priority: major Milestone: sage-8.9
Component: interfaces: optional Keywords: macaulay2
Cc: Merged in:
Authors: Markus Wageringel Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 53c4f23 (Commits, GitHub, GitLab) Commit: 53c4f2321cea2cacd1792bfa2918f5e6e400809a
Dependencies: Stopgaps:

Status badges

Description

This ticket improves the string representation of Macaulay2 elements that usually acquire the name of the global variable they are assigned to, such as polynomial rings and varieties.

Currently, Sage implicitly calls describe to get a string representation that avoids the global names, in particular those of internal Expect variables sage0, sage1,… which are not meaningful to a user. This ticket changes the assignment operator for these internal variables from = to <- to keep internal variables from acquiring the names, which was suggested by the developers upstream. As a result, calling describe is no longer necessary and the string representation becomes much nicer. Previously, this output could not be obtained at all (this is what describe used to return in old versions of M2):

sage: macaulay2('QQ[x,y,z]')
QQ[x, y, z]

It is still possible to call describe explicitly:

sage: macaulay2('QQ[x,y,z]').describe()
QQ[x..z, Degrees => {3:1}, Heft => {1}, MonomialOrder => {MonomialSize => 32}, DegreeRank => 1]
                                                         {GRevLex => {3:1}  }
                                                         {Position => Up    }

Also, if a user specifies the variable name, the element assumes that name as usual in Macaulay2:

sage: R = macaulay2('QQ[x,y,z]', 'R'); R
R

Change History (5)

comment:1 Changed 3 years ago by Markus Wageringel

Authors: Markus Wageringel
Branch: u/gh-mwageringel/28303
Commit: 53c4f2321cea2cacd1792bfa2918f5e6e400809a
Status: newneeds_review

This also includes small improvements to the documentation of the interface. I tested this using Macaulay2 version 1.12 and 1.14 with Python 2 and 3.


New commits:

53c4f2328303: improve assignment of internal Macaulay2 variables

comment:2 Changed 3 years ago by Frédéric Chapoton

ok, looks good. Maybe we should keep an example about matrices ?

comment:3 Changed 3 years ago by Markus Wageringel

There are examples in matrix1.pyx. The test I removed was meant to specifically test the workaround for matrices, but that is no longer needed if we do not call describe anymore.

comment:4 Changed 3 years ago by Frédéric Chapoton

Reviewers: Frédéric Chapoton
Status: needs_reviewpositive_review

ok, then.

comment:5 Changed 3 years ago by Volker Braun

Branch: u/gh-mwageringel/2830353c4f2321cea2cacd1792bfa2918f5e6e400809a
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.