Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
include macros functions in rule._function #451
alubbock left a comment
@with_model def test_function_introspection(): # Case 1: Component defined inside function Monomer('A') assert A._function == 'test_function_introspection' # Case 2: Component defined inside nested function def define_monomer_b(): Monomer('B') define_monomer_b() assert B._function == 'define_monomer_b' # Case 3: Component defined by macro from pysb.macros import equilibrate equilibrate(A(), B(), [1, 1]) print(model.rules) assert model.rules['equilibrate_A_to_B']._function == 'equilibrate' # Case 4: Component defined by macro inside function def define_macro_inside_function(): Monomer('C') equilibrate(A(), C(), [2, 2]) define_macro_inside_function() assert model.rules['equilibrate_A_to_C']._function == 'equilibrate'
This makes me think this feature should be under more user control, as some might want macros included, some might not, and some might indeed want the whole stack. We shouldn't try to make the existing code any hairier than it already is, but in a future version maybe we can work out a way to reengineer this feature "orthogonally" to the Component class itself.