从我自己的软件包内的参数导入@with_kw

发布于 2025-01-27 21:53:54 字数 927 浏览 2 评论 0原文

我创建了我自己的julia package 我是这种做法的新手。

我以前有这个代码:

using Parameters
@with_kw mutable struct MWE @deftype String
mwe1 = "default" ; @assert mwe1 in ["default", "1", "2"]
mwe2 = "test"
end

效果很好。现在,我将其放入软件包中,用用导入替换,我有以下错误:

julia> import MyPackageMWE
[ Info: Precompiling RobustRSP [33e6bdf6-6d3e-458b-9f4e-8cd6eb784281]
[ Info: Loading JuMP
[ Info: Loading Gurobi
[ Info: Loading Combinatorics, DelimitedFiles, Dates and Random
[ Info: Loading Distributions, Graphs and Plots
[ Info: Loading Parameters and Formatting
[ Info: Loading Compose, Cairo and Fontconfig
[ Info: Loading .jl files   0%
ERROR: LoadError: UndefVarError: @with_kw not defined

有什么想法出了什么问题? 也许与@macros有关?

I have created my own Julia package and I am new to such practices.

I previously had this code:

using Parameters
@with_kw mutable struct MWE @deftype String
mwe1 = "default" ; @assert mwe1 in ["default", "1", "2"]
mwe2 = "test"
end

Which worked well. Now that I put it into my package, replacing using with import, I have the following error:

julia> import MyPackageMWE
[ Info: Precompiling RobustRSP [33e6bdf6-6d3e-458b-9f4e-8cd6eb784281]
[ Info: Loading JuMP
[ Info: Loading Gurobi
[ Info: Loading Combinatorics, DelimitedFiles, Dates and Random
[ Info: Loading Distributions, Graphs and Plots
[ Info: Loading Parameters and Formatting
[ Info: Loading Compose, Cairo and Fontconfig
[ Info: Loading .jl files   0%
ERROR: LoadError: UndefVarError: @with_kw not defined

Any ideas what went wrong?
Maybe it is related to @macros?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦÷微暖 2025-02-03 21:53:54

我不知道软件包参数,但可能是,如果@with_kw在参数中导出,则如果您

using Parameters

import Parameters

替换
@with_kw带有参数。@with_kw

I don't know the package Parameters but it may be that if @with_kw is exported in Parameters then if you replace

using Parameters

with

import Parameters

then you should change
@with_kw with Parameters.@with_kw

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文