From 27353caed2c25e7e6f6335a0a3cff7f57f03d220 Mon Sep 17 00:00:00 2001 From: Lalit Chauhan Date: Fri, 21 Jul 2023 01:38:38 +0530 Subject: [PATCH] Change metadata allocation to allocate within the macro --- src/compound.jl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/compound.jl b/src/compound.jl index a2a8b22528..a82baac370 100644 --- a/src/compound.jl +++ b/src/compound.jl @@ -46,9 +46,6 @@ macro compound(species_expr, arr_expr...) coeffs_expr = Expr(:vect, coeffs...) species_expr = Expr(:vect, species...) - # Ensure the expression is evaluated in the correct scope by escaping it - escaped_setcomponentcoefficients_expr = esc(setcomponentcoefficients_expr) - # Construct the expression to set the components metadata setcomponents_expr = :($(species_name) = ModelingToolkit.setmetadata($(species_name), Catalyst.CompoundComponents, @@ -66,7 +63,7 @@ macro compound(species_expr, arr_expr...) # Return a block that contains the escaped expressions return Expr(:block, escaped_species_expr, escaped_setmetadata_expr, - escaped_setcomponents_expr, escaped_setcoefficients_expr, escaped_setcomponentcoefficients_expr) + escaped_setcomponents_expr, escaped_setcoefficients_expr) end # Check if a species is a compound @@ -85,11 +82,6 @@ function components(s) MT.getmetadata(s, CompoundComponents) end -component_coefficients(s::Num) = component_coefficients(MT.value(s)) -function component_coefficients(s) - MT.getmetadata(s, CompoundComponentCoefficients) -end - component_coefficients(s::Num) = component_coefficients(MT.value(s)) function component_coefficients(s) return [c => co for (c, co) in zip(components(s), coefficients(s))]