Ask Your Question
2

Diamond brackets <> and square brackets [] notations

asked 2020-04-05 20:27:28 +0100

petRUShka gravatar image

updated 2020-04-06 12:05:26 +0100

Are there some documentation on diamond bracket notation:

R.<w> = PolynomialRing(QQ)

and square bracket notation:

R.<y> = QQ['y'];

There is some documentation in Constructors for polynomial rings docs but it looks superficial on this topic.

Are there some complete explanation with all the details behind the scene?

Is it only for polynomial rings or for some other objects? Is it SageMath addition?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2020-04-05 20:47:03 +0100

Sébastien gravatar image

updated 2020-04-05 20:53:54 +0100

Indeed, this is not Python syntax, it is SageMath syntax only. Sage preparses this notation and turns it into Python code:

sage: preparse('R.<w> = PolynomialRing(QQ)')
"R = PolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1)"

Other examples include:

sage: preparse('2/3')
'Integer(2)/Integer(3)'
sage: preparse('2./3')
"RealNumber('2.')/Integer(3)"
sage: preparse('x^x')
'x**x'

Also, this turns off/on the preparser:

sage: preparser(False)
sage: preparser(True)
edit flag offensive delete link more

Comments

1

Note that this does not exactly answers the question which started with "Are there some documentation ..."

vdelecroix gravatar imagevdelecroix ( 2020-04-05 21:16:35 +0100 )edit

The relevant documentation is for the function preparse_generators: http://doc.sagemath.org/html/en/refer.... There are more examples (labeled as "TESTS") which are in the code but not the reference manual.

John Palmieri gravatar imageJohn Palmieri ( 2020-04-05 22:34:01 +0100 )edit
3

Some documentation on that syntax can also be found in the section on A Guided tour on Polynomial of the Tutorial of SageMath at http://doc.sagemath.org/html/en/tutor... But it is true that some clearer documentation on this syntax could be explained on its own chapter somewhere.

Sébastien gravatar imageSébastien ( 2020-04-06 09:46:41 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-04-05 20:27:28 +0100

Seen: 3,303 times

Last updated: Apr 06 '20