sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.35k stars 461 forks source link

Polymake: Better syntax to call functions with <template arguments> #27861

Open mkoeppe opened 5 years ago

mkoeppe commented 5 years ago

Currently we have to write:

sage: polymake("tropical::uniform_linear_space<Max>(3,2)")

or

sage: getattr(polymake, "tropical::uniform_linear_space<Max>")(3, 2)

or

sage: polymake.function_call("tropical::uniform_linear_space<Max>", [3, 2])

because the template brackets cannot become part of the Python function name, so the normal . syntax cannot work.

(Also, but not the point of this ticket - #27736: Polymake: Turn polymake applications into objects with directories.)

Also,

    polymake("tropical::uniform_linear_space<Max>")(3,2)

does not work. It looks for an overloaded function without arguments, which fails:

    TypeError: no matching overloaded instance of Polymake::tropical::uniform_linear_space<Max>()

Also,

sage: polymake.call("tropical::uniform_linear_space<Max>", 3, 2)

does not work -- the undocumented and untested call method passes the args tuple to function_call, which expects lists instead of tuples.

CC: @simon-king-jena @jplab @dimpase

Component: packages: experimental

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

embray commented 5 years ago
comment:1

As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).

mkoeppe commented 5 years ago

Description changed:

--- 
+++ 
@@ -3,7 +3,14 @@
 polymake("tropical::uniform_linear_space<Max>(3,2)")
-because the template brackets cannot become part of the Python function name.
+or
+
+```
+sage: getattr(polymake, "tropical::uniform_linear_space<Max>")(3, 2)
+Uniform linear space of dimension 2 in dimension 3
+```
+because the template brackets cannot become part of the Python function name, so the normal `.` syntax cannot work.
+ 
 (Also, but not the point of this ticket - #27736: Polymake: Turn polymake applications into objects with directories.)

 Also, 
mkoeppe commented 5 years ago

Description changed:

--- 
+++ 
@@ -1,13 +1,17 @@
 Currently we have to write:

@@ -18,10 +22,15 @@

     polymake("tropical::uniform_linear_space<Max>")(3,2)

-does not work -- we cannot seem to create this function object. It looks for an overloaded function without arguments, which fails: +does not work. It looks for an overloaded function without arguments, which fails:

     TypeError: no matching overloaded instance of Polymake::tropical::uniform_linear_space<Max>()

+Also,

+ +sage: polymake.call("tropical::uniform_linear_space<Max>", 3, 2) + +does not work -- the undocumented and untested call method passes the args tuple to function_call, which expects lists instead of tuples.

mkoeppe commented 4 years ago
comment:4

Moving some tickets to 9.2. This is not a promise that I will be working on them.

mkoeppe commented 3 years ago
comment:6

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.