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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyhedron function broken with floats in sage-6.3 (worked in sage-6.2) #17264

Closed
williamstein opened this issue Oct 30, 2014 · 12 comments
Closed

Comments

@williamstein
Copy link
Contributor

If you try to make the convex hull of a set of points given by float coordinates using Polyhedron, this worked fine in Sage-6.2, but is broken in Sage-6.3.

sage: Polyhedron([(0.8370682893845995r, 0.2027977776670088r, 0.2547890063224252r)])
AttributeError: type object 'float' has no attribute 'fraction_field'
sage: Polyhedron([(0.8370682893845995, 0.2027977776670088, 0.2547890063224252)])
A 0-dimensional polyhedron in (Real Field with 54 bits of precision)^3 defined as the convex hull of 1 vertex

I noticed when making this interact:

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2014-10-30-105145-convex-hull-interact.sagews

This is also still broken in sage-6.4.rc0:

/scratch/wstein/sage-6.4.rc0$ ./sage
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.4.rc0, Release Date: 2014-10-30                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: Polyhedron([(0.8370682893845995r, 0.2027977776670088r, 0.2547890063224252r)])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-69a05f87fbc6> in <module>()
----> 1 Polyhedron([(0.8370682893845995, 0.2027977776670088, 0.2547890063224252)])
 
/scratch/wstein/sage-6.4.rc0/local/lib/python2.7/site-packages/sage/misc/lazy_import.so in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/laz
y_import.c:3230)()
 
/scratch/wstein/sage-6.4.rc0/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    703                     kwds[new_name] = kwds[old_name]
    704                     del kwds[old_name]
--> 705             return func(*args, **kwds)
    706
    707         return wrapper
 
/scratch/wstein/sage-6.4.rc0/local/lib/python2.7/site-packages/sage/geometry/polyhedron/constructor.pyc in Polyhedron(vertices, rays, lines, ieqs, eqns, ambient_dim
, base_ring, minimize, verbose, backend)
    444     # Specific backends can override the base_ring
    445     from sage.geometry.polyhedron.parent import Polyhedra
--> 446     parent = Polyhedra(base_ring, ambient_dim, backend=backend)
    447     base_ring = parent.base_ring()
    448
 
/scratch/wstein/sage-6.4.rc0/local/lib/python2.7/site-packages/sage/geometry/polyhedron/parent.pyc in Polyhedra(base_ring, ambient_dim, backend)
     84         return Polyhedra_RDF_cdd(RDF, ambient_dim)
     85     elif backend == 'field':
---> 86         return Polyhedra_field(base_ring.fraction_field(), ambient_dim)
     87     else:
     88         raise ValueError('No such backend (='+str(backend)+
 
AttributeError: type object 'float' has no attribute 'fraction_field'
sage:  

Component: geometry

Keywords: days88

Reviewer: Vincent Delecroix, Jean-Philippe Labbé

Issue created by migration from https://trac.sagemath.org/ticket/17264

@williamstein williamstein added this to the sage-6.4 milestone Oct 30, 2014
@kcrisman
Copy link
Member

kcrisman commented Nov 3, 2014

comment:1

Is this only true for floats, though?

@kcrisman kcrisman changed the title Polyhedron function broken in sage-6.3 (worked in sage-6.2) Polyhedron function broken with floats in sage-6.3 (worked in sage-6.2) Nov 3, 2014
@novoselt
Copy link
Member

novoselt commented Nov 5, 2014

comment:2

Probably. is_field(float) does not work as well, by the way.

The fix is to either allow float though as the base field or replace it with RDF. I suspect the second option is less error-prone.

@novoselt
Copy link
Member

novoselt commented Mar 9, 2017

comment:3

Still breaks in 7.6.beta6...

@jplab
Copy link

jplab commented Mar 10, 2017

comment:4

This should be looked at after #18220 gets merged.

@jplab
Copy link

jplab commented Mar 15, 2017

comment:5

In 7.6.rc0 it now gives:


sage: Polyhedron(vertices = [(0.8370682893845995r, 0.2027977776670088r, 0.2547890063224252r)])
Traceback (most recent call last):
...
     89         elif base_ring is RDF:
     90             backend = 'cdd'
---> 91         elif base_ring.is_exact():
     92             backend = 'field'
     93         else:

AttributeError: type object 'float' has no attribute 'is_exact'

and


sage: Polyhedron([(0.8370682893845995, 0.2027977776670088, 0.2547890063224252)])
Traceback (most recent call last):
...
ValueError: no appropriate backend for computations with Real Field with 54 bits of precision

The last one is caused by #18220.

I guess that the first one should also return a ValueError saying that no backend deals with polyhedron over floats.

Maybe even a pointer to say that it should be done in RDF?

@jplab
Copy link

jplab commented Mar 17, 2017

comment:6

The ticket #22605 aims to make the error messages for base ring more informative and suggested to redirect floats to the base ring RDF.

@videlec
Copy link
Contributor

videlec commented Aug 19, 2017

comment:7

Fixed (or at least coherent) in 8.1.beta2

sage: Polyhedron([(0.8370682893845995r, 0.2027977776670088r, 0.2547890063224252r)])
A 0-dimensional polyhedron in RDF^3 defined as the convex hull of 1 vertex
sage: Polyhedron([(0.8370682893845995, 0.2027977776670088, 0.2547890063224252)])
Traceback (most recent call last):
...
ValueError: no appropriate backend for computations with Real Field with 54 bits of precision

(see #22605)

@videlec videlec removed this from the sage-6.4 milestone Aug 19, 2017
@jplab
Copy link

jplab commented Aug 21, 2017

comment:8

Indeed, #22605 seems to deal with that issue properly.

@jplab
Copy link

jplab commented Aug 21, 2017

Changed keywords from none to days88

@kevindilks
Copy link
Mannequin

kevindilks mannequin commented Aug 21, 2017

comment:9

Needs Author and Reviewer.

@jplab
Copy link

jplab commented Aug 21, 2017

Reviewer: Vincent Delecroix, Jean-Philippe Labbé

@jplab
Copy link

jplab commented Aug 21, 2017

comment:10

Nothing was written so we won't put authors...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants