saulpw / aipl

Array-Inspired Pipeline Language
MIT License
119 stars 7 forks source link

Rankout of 0.5 that goes directly to `call_cmd` will return a dict #44

Open anjakefala opened 1 year ago

anjakefala commented 1 year ago
 !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:

Screenshot from 2023-06-11 22-48-12 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. 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.

Originally posted by @anjakefala in https://github.com/saulpw/aipl/issues/23#issuecomment-1586627156