When is !format unable to find a reference?
anjakefala opened this issue · 3 comments
!literal>feigenbaum
4.66920
!!python
from aipl import defop
from aipl.table import Table
@defop('test', 1.5, 0)
def testtest(aipl, t:Table) -> str:
return '42'
!test
!format
{feigenbaum}
# AIPL Error (line 11 !format): 'feigenbaum'
!print
Hypothesis: rankout 0 and 0.5 do not set the __parent
. Only 1
and 1.5
do. Since !test
in this case also replaces the source table, feigenbaum
is lost.
Yes, I changed the rankout of !test
to 1, and aipl was able to find {feigenbaum}
even with the table replaced.
Rankouts of 0 and 0.5, that replace the top-level table, lose their __parent
.
There are a couple of other problems.
!literal>feigenbaum
4.66920
!!python
from aipl import defop
from aipl.table import Table
@defop('test', 1.5, 0.5)
def testtest(aipl, t:Table) -> str:
return dict(theanswer='42')
!test
!format
{feigenbaum}
# AIPL Error (line 11 !format): 'feigenbaum'
!print
Will result in a table that looks like this:
This is because we went directly into call_cmd without going through any of the recursion steps in eval_op.
This means that we never convert the dict returned by !test
into a LazyRow with columns. Even if I try to add a __parent
in the prep_output, the structure of the table gets interpreted as a LazyRow that is holding a dict that also contains a __parent
key, and !format
won't know to search through it.