From 46df8a4668ca9f88ed08cd6d261a497d7c823d93 Mon Sep 17 00:00:00 2001 From: Venkateshprasad <32921645+ven-k@users.noreply.github.com> Date: Mon, 4 Dec 2023 18:53:11 +0530 Subject: [PATCH] feat: extend `Base.parentmodule` for `Model` --- src/systems/model_parsing.jl | 2 ++ test/model_parsing.jl | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/systems/model_parsing.jl b/src/systems/model_parsing.jl index 22f2c42587..65d3cd987d 100644 --- a/src/systems/model_parsing.jl +++ b/src/systems/model_parsing.jl @@ -24,6 +24,8 @@ struct Model{F, S} end (m::Model)(args...; kw...) = m.f(args...; kw...) +Base.parentmodule(m::Model) = parentmodule(m.f) + for f in (:connector, :mtkmodel) isconnector = f == :connector ? true : false @eval begin diff --git a/test/model_parsing.jl b/test/model_parsing.jl index 3a0991cdff..52c769f0b0 100644 --- a/test/model_parsing.jl +++ b/test/model_parsing.jl @@ -577,3 +577,15 @@ end @test getdefault(component.written_out_for_1.sc) == 2 @test getdefault(component.written_out_for_2.sc) == 3 end + +module GetParentModule + +using ModelingToolkit + +@mtkmodel Component begin end + +end + +@testset "Parent module of Models" begin + @test parentmodule(GetParentModule.Component) == GetParentModule +end