#28855 closed defect (fixed)

PolynomialRing random_element()s aren't always ring elements

Reported by: mjo Owned by:
Priority: major Milestone: sage-9.1
Component: algebraic geometry Keywords:
Cc: Merged in:
Authors: Michael Orlitzky Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 63e6767 (Commits, GitHub, GitLab) Commit: 63e67676517f18ed9503ee48af5a3e628f43032a
Dependencies: Stopgaps:

Status badges


When you pass degree=0 to the PolynomialRing random_element() method, it short-circuits and gives you back an element of the base ring rather than an element of the polynomial ring:

sage: R = PolynomialRing(QQ, 'X,Y,Z')
sage: type(R.random_element(degree=0))
<class 'sage.rings.rational.Rational'>

This means that you need special cases in all of your algorithms, because that random element won't have an lt() method, for example. I think it's an easy fix to wrap that ring element in self(), so long as nothing else breaks as a result.

Change History (3)

comment:1 Changed 22 months ago by mjo

  • Authors set to Michael Orlitzky
  • Branch set to u/mjo/ticket/28855
  • Commit set to 63e67676517f18ed9503ee48af5a3e628f43032a
  • Status changed from new to needs_review

I guess it was easy, unless I come back in a few hours to report that ptestlong threw up.

New commits:

0d51b5aTrac #28855: always return PolynomialRing elements from random_element().
63e6767Trac #28855: whitespace/comment cleanup in multivariate polynomial rings.

comment:2 Changed 21 months ago by chapoton

  • Milestone changed from sage-9.0 to sage-9.1
  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review


comment:3 Changed 21 months ago by vbraun

  • Branch changed from u/mjo/ticket/28855 to 63e67676517f18ed9503ee48af5a3e628f43032a
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.