Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10320 closed defect (wontfix)

__len__ still used in polyhedra.py

Reported by: jplabbe Owned by: mhampton
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: geometry Keywords: polyhedron, len
Cc: Merged in:
Authors: JP Labbé Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

When you create the 3-dimensional permutahedron by hand (because one could use polytopes.permutahedron(4) instead), this yields an AttributeError?. The init function of Polyhedron uses the function len(x), but it has been removed.

sage: P=Polyhedron(Permutations([1,2,3,4]))
----------------------------------
AttributeError     Traceback (most recent call last)

sage-4.6/<ipython console> in <module>()

sage-4.6/local/lib/python2.6/site-packages/sage/geometry
/polyhedra.pyc in __init__(self, vertices, rays, lines, ieqs, eqns,
field, compute_adjacency, verbose)
   1507 
   1508         # Clean up the arguments
-> 1509         vertices = _set_to_None_if_empty(vertices)
   1510         rays     = _set_to_None_if_empty(rays)
   1511         lines    = _set_to_None_if_empty(lines)

sage-4.6/local/lib/python2.6/site-packages/sage/geometry
/polyhedra.pyc in _set_to_None_if_empty(x)
    184     """
    185     if x==None: return x
--> 186     if len(x)==0: return None
    187     return x
    188 

sage-4.6/local/lib/python2.6/site-packages/sage/combinat
/combinat.pyc in __len__(self)
    888             AttributeError: __len__ has been removed; use .cardinality() instead
    889         """
--> 890         raise AttributeError, "__len__ has been removed; use .cardinality() instead"
    891 
    892     def count(self):

AttributeError: __len__ has been removed; use .cardinality() instead
sage:

Change History (3)

comment:1 follow-up: Changed 11 years ago by mhampton

  • Resolution set to wontfix
  • Status changed from new to closed

I don't see this as a bug; the input needs to be a list, so you should do:

sage: P=Polyhedron(list(Permutations([1,2,3,4])))

instead.

I am open to counter-arguments but I am marking this "won't fix" for now.

comment:2 Changed 11 years ago by mvngu

  • Milestone changed from sage-4.6.1 to sage-duplicate/invalid/wontfix

comment:3 in reply to: ↑ 1 Changed 11 years ago by jplabbe

I don't see this as a bug; the input needs to be a list, so you should do:

sage: P=Polyhedron(list(Permutations([1,2,3,4])))

instead.

I see! My bad!

I am open to counter-arguments but I am marking this "won't fix" for now.

That's perfect!

Note: See TracTickets for help on using tickets.