Closed mmasdeu closed 7 years ago
Should be fixed in 68486df
Thanks for actively improving this! Still segfaults, though.
Which Sage version are you using? For me M.<tab>
just gives nothing.
and
sage: M = P.FACETS
polymake: used package ppl
The Parma Polyhedra Library (PPL): A C++ library for convex polyhedra
and other numerical abstractions.
http://www.cs.unipr.it/ppl/
sage: M
[ 1 -1 -2 0]
[ 0 -1 -2 1]
[ 0 1 -2 0]
[ 0 0 1 0]
sage: type(M)
<type 'polymake.matrix.MatrixRational'>
I'm using 7.3, but the segfault occurs from within python. I use python 2.7.12 on an Arch Linux install.
On Wed, Sep 14, 2016 at 1:42 PM, Vincent Delecroix <notifications@github.com
wrote:
Which Sage version are you using? For me M.
just gives nothing. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videlec/pypolymake/issues/9#issuecomment-247000441, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkAIkrtd4W4Nd1RZqxtrp7whliqakS4ks5qp-uygaJpZM4J8mhj .
At which point does it segfault precisely? Note that tab completion only concerns IPython.
From Sage it's worse:
from polymake import polytope
P = polytope.Polytope('POINTS',[[18,10,4,18],[16,8,4,18],[16,8,4,16],[1,1,0,1],[0,0,0,1],[1,0,0,0]])
Gives a ValueError: not able to convert 18 to rational
(which I understand comes from the conflicting types Integer and Rational between pypolymake and Sage...)
I got the same, it should be
sage: P = polymake.polytope.Polytope('POINTS',[[18r,10r,4r,18r],[16r,8r,4r,18r],[16r,8r,4r,16r] [1r,1r,0r,1r],[0r, 0r,0r,1r],[1r,0r,0r,0r]])
(I hope to fix this soon)
If I do M.name() it segfaults as well.
On Wed, Sep 14, 2016 at 1:49 PM, Vincent Delecroix <notifications@github.com
wrote:
At which point does it segfault precisely? Note that tab completion only concerns IPython.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videlec/pypolymake/issues/9#issuecomment-247002196, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkAIpsBvgxUfz60xCH8hb8LVUUuz5MMks5qp-1qgaJpZM4J8mhj .
OK I can initialize the polytope now (note there is a comma missing in your example). I then do:
M = P.VERTICES_IN_FACETS
Doing anything like M[0,0]
does not work. But then M.name()
segfaults
too.
On Wed, Sep 14, 2016 at 1:51 PM, Vincent Delecroix <notifications@github.com
wrote:
I got the same, it should be
sage: P = polymake.polytope.Polytope('POINTS',[[18r,10r,4r,18r],[16r,8r,4r,18r],[16r,8r,4r,16r] [1r,1r,0r,1r],[0r, 0r,0r,1r],[1r,0r,0r,0r]])
(I hope to fix this soon)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videlec/pypolymake/issues/9#issuecomment-247002625, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkAIrMlUjrap2SYmtwz1uU81udmTwXZks5qp-3QgaJpZM4J8mhj .
VERTICES_IN_FACETS does return an incidence matrix (i.e. a matrix with 0/1 entries). There is currently no handler for that (see the file properties.pyx).
For .name()
and .description()
it does segfault and I have no idea how to fix that (except removing the methods).
When using polymake directly, the "method" VERTICES_IN_FACETS returns what looks like a list of sets:
polytope > print $p->VERTICES_IN_FACETS;
polymake: used package ppl
The Parma Polyhedra Library (PPL): A C++ library for convex polyhedra
and other numerical abstractions.
http://www.cs.unipr.it/ppl/
{0 1 3 4 5} {0 1 2 3 4} {1 2 4 5} {2 3 4 5} {0 2 3 5} {0 1 2 5}
I would like a way to get this from within Sage. I will take a look at the properties.pyx to see whether/how this can be done... Thanks!
I see. You can get the string corresponding to the C++ type with
sage: M.type_name()
'IncidenceMatrix<NonSymmetric>'
Then you have to look in the polymake source code where it is. Then it should be declare appropriately in defs.pxd
. Then you can write some Python bindings for it. And then providing a handler in properties.pyx
(you might just need to copy paste what is done for other handlers).
With great effort (interfacing cpp/perl/cython/python is at the limit of my programming skills) I have managed to make it work (I will fork this hopefully soon). But then I discovered that VERTEX_LABELS is of type Array
Good! I think that the array class is standard C++ (from STL). There is a hope to make something simple there.
anything new?
Take a look at my fork (https://github.com/mmasdeu/pypolymake). I have Sage code that successfully uses pypolymake (still work in progress), so that is good news! I would be very interested in improving pypolymake, but interfacing each function manually seems like a daunting task! Is there any other option in sight? What are your plans?
Wonderful! My ultimate goal is to avoid using perl as much as possible. Polymake is mostly written in C++ and interfaced via perl. It should be possible to have the same kind of bindings from Python bypassing the perl interface.
Here is a snippet that does not work in my installation.
P = polymake.polytope.Polytope('POINTS',[[18,10,4,18],[16,8,4,18],[16,8,4,16],[1,1,0,1],[0,0,0,1],[1,0,0,0]])
M = P.FACETS
M.
and then press TAB. This causes a segfault. What I really would like is a way to get the facets of P, but it turns out that M is a Perl rational matrix, and I can't figure out how to get its entries...