REGnosys / rosetta-code-generators

Write code generators for any language, based on the rosetta DSL
Apache License 2.0
17 stars 33 forks source link

Python generator - defects in the runtime functions #366

Open priyanka-amarnani opened 3 days ago

priyanka-amarnani commented 3 days ago

Description: A recent testing of the project identified several defects in the runtime functions and in the generator code . Below is a detailed description of the identified issues.

  1. _resolve_rosettaattr: Most of the functions, in order to work with the input, use frames for the ‘self’ object. The _resolve_rosetta_attr, used to get an attribute from an object, doesn't support an object of type frame. This makes it impossible to access the atributes within the frame.
  2. _check_one_ofconstraint: Similar to the previous situation, _check_one_ofconstraint is defined within the BaseDataModel context, the function fails to run on the provided input as it doesn't support the object of type frame.
  3. _allelements: This function compares two lists, but the function compares the lists element by element. For example, if L1= [‘True’, ‘False’] and L2=[‘True’,’False’], the function would compare L1[0]=’True’ with L2[0]=’True’ and would proceed to compare L1[0]=’True’ with L2[1]=’False’, defining both the lists as different as the last comparison would be false.
  4. _flattenlist: This function flattens lists of lists, but fails to flatten the lists when the input containts a nested list.
  5. map operator: the map opertaor has an unexpected behaviour, ideally the operator should apply a function and return a map iterable. The current implementation, doesn't apply the function and returns the input without any changes.
  6. _rosettafilter:The generation of the filter function, doesn't use the 'item' syntax within the lambda function logic. This results in an incorrect output.

Expected behaviour: The python code generator and the runtime functions should fix the mentioned defects to ensure the expected results.

SimonCockx commented 2 days ago

@dschwartznyc Something you might be interested in.