Skip to content

Macro dependencies are not properly solved #449

@enekomartinmartinez

Description

@enekomartinmartinez

Macro objects have all the parameters as initial and step dependencies. This could lead to some circular initialization error when it shouldn't. For example, model below

:MACRO: MYMACRO(A, B)
 
mymacro = INTEG(A, B) ~~|
 
:END OF MACRO:


my_var = MYMACRO(var1, var2) ~~|

var1 = INITIAL(my_var) ~~|

var2 = 0 ~~|

dependencies for my_var are translated as

@component.add(
    name="my_var",
    comp_type="Auxiliary",
    comp_subtype="Normal",
    depends_on={"_macro_mymacro_my_var": 1},
    other_deps={
        "_macro_mymacro_my_var": {
            "initial": {"var1": 1, "var2": 1},
            "step": {"var1": 1, "var2": 1},
        }
    },
)

which leads to a circular initialization error, when they should be translated as

@component.add(
    name="my_var",
    comp_type="Auxiliary",
    comp_subtype="Normal",
    depends_on={"_macro_mymacro_my_var": 1},
    other_deps={
        "_macro_mymacro_my_var": {
            "initial": {"var2": 1},
            "step": {"var1": 1},
        }
    },
)

This requires building first the macros and resolving the dependencies in the SectionBuilder level, so they can be properly accessed by the macro call builder.

FYI @mak63-dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions