Opened 12 years ago

Closed 12 years ago

# __len__ still used in polyhedra.py

Reported by: Owned by: jplabbe mhampton major sage-duplicate/invalid/wontfix geometry polyhedron, len JP Labbé N/A

### 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,
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:
```

### comment:1 follow-up: ↓ 3 Changed 12 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])))

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

### comment:2 Changed 12 years ago by mvngu

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

### comment:3 in reply to: ↑ 1 Changed 12 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])))