Opened 8 months ago

Closed 7 months ago

#28770 closed defect (fixed)

Polyhedra coercion of base rings fails for number fields

Reported by: gh-kliem Owned by:
Priority: major Milestone: sage-9.0
Component: geometry Keywords:
Cc: jipilab, gh-LaisRast Merged in:
Authors: Jonathan Kliem Reviewers: Léo Brunswic
Report Upstream: N/A Work issues:
Branch: a0068cc (Commits) Commit: a0068ccbab09b0102a64c5fbe4ffaffa71b44086
Dependencies: Stopgaps:

Description (last modified by gh-kliem)

Currently coercion of polyhedra with number fields does not work. The following results in a type error:

sage: z = QQ['z'].0                                          
sage: K = NumberField(z^2 - 2,'s')
sage: K.gen()*polytopes.simplex(backend='field')

But the backend can surely handle it, as the following does work:

sage: z = QQ['z'].0                                          
sage: K = NumberField(z^2 - 2,'s')
sage: K.gen()*polytopes.simplex(backend='field', base_ring=K)
A 3-dimensional polyhedron in (Number Field in s with defining polynomial z^2 - 2)^4 defined as the convex hull of 4 vertices

The underlying error:

sage: z = QQ['z'].0                                          
sage: K = NumberField(z^2 - 2,'s')
sage: parent = polytopes.simplex().parent()
sage: parent._coerce_base_ring(K)
Rational Field

But it should be K.

The problem is that _coerce_base_ring of Polyhedra_base just takes the base ring of K, which are the rationals.

We fix this, by not taking the base ring, if the object is already a ring.

Change History (6)

comment:1 Changed 8 months ago by gh-kliem

  • Branch set to public/28770
  • Commit set to a272cfdb26a536eeb804ca2c66bf6660c27a79b5
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

a272cfdfix coercion of polyhedra with number fields

comment:2 Changed 8 months ago by git

  • Commit changed from a272cfdb26a536eeb804ca2c66bf6660c27a79b5 to a0068ccbab09b0102a64c5fbe4ffaffa71b44086

Branch pushed to git repo; I updated commit sha1. New commits:

a0068ccadded a doctest for the original bug

comment:3 Changed 8 months ago by gh-LBrunswic

  • Status changed from needs_review to positive_review

comment:4 Changed 8 months ago by chapoton

reviewer full name is missing

comment:5 Changed 8 months ago by gh-kliem

  • Reviewers set to Léo Brunswic

comment:6 Changed 7 months ago by vbraun

  • Branch changed from public/28770 to a0068ccbab09b0102a64c5fbe4ffaffa71b44086
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.