在Julia中是否有一种简单的方法来检查当前工作目录中的文件是否存在(类似于test = os.path.isfile("foo.txt")Python或inquire(file = "foo.txt", exist = test)Fortran中的文件)?
我试图在astropy.modelling中使用Model.tied(或Parameter.tied)属性,但似乎无法弄清楚它是如何工作的.例如,假设我想创建一个包含两个参数的复合模型:flux_0和flux_1.但是,我只想flux_0在拟合中使用:flux_1应始终携带值1 - flux_0.(最后,我需要扩展此功能,以便flux_0 + flux_1 + ... + flux_n = 1.)
我为这个tied属性定义了一个模型类和一个"callable",如下所示:
>>> from astropy.modeling import Fittable1DModel, Parameter
>>>
>>> class MyModel(Fittable1DModel):
... flux = Parameter()
... @staticmethod
... def evaluate(x, flux):
... return flux
...
>>> def tie_fluxes(model):
... flux_1 = 1 - model.flux_0
... return flux_1
...
>>> TwoModel = MyModel + MyModel
>>>
>>> TwoModel
<class '__main__.CompoundModel0'>
Name: CompoundModel0 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Gtk 在 Julia 中制作 GUI 程序。我的程序包含大量的 GtkEntry 框。但是,我遇到了空间问题,因为输入框在实际字符周围有很多内部填充。我想至少减少顶部和底部的空白。我尝试过使用该setproperty!()函数来更改height-request值,但这似乎只能使框变大,而不能变小。另外,margin、margin-top等字段默认均设置为0。再说一遍,我可以让它们变大,但不能变小。
这可以修复吗?我在下面提供了一个最小的工作示例、一个屏幕截图和一个显示可用属性的 Julia REPL 输出。
编辑: 我还尝试使用 css 文件(test.css)及其内容
entry {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)
朱莉娅 0.6.0 代码:
using Gtk
win = GtkWindow("Example")
sb = GtkGrid()
function sb_entry(label)
frame = GtkFrame(label)
entry = GtkEntry()
setproperty!(entry, :input_purpose, 2)
push!(frame, entry)
return frame
end
sb_rows = sb_entry("rows")
sb_cols = sb_entry("cols")
sb_row_off = sb_entry("row off")
sb_col_off = sb_entry("col off")
sb[1,1] = sb_rows …Run Code Online (Sandbox Code Playgroud) 我是朱莉娅的新手.我正在寻找一种方法将50个文本文件中的值输入到数组中.文件以data-X.datX为整数1-50 的形式命名.文件格式如下(我无法控制格式):
garbage text
comment: words = I1, more words = I2
more garbage text
blah blah = F1
measurement = F2 F3 text
Run Code Online (Sandbox Code Playgroud)
其中I1和I2是整数和F1,F2和,F3是十进制形式的数字(例如12.345).我想将数据转储到数组中,例如,数组的第三个元素i1是I1文件中的值data-3.dat.
我如何在朱莉娅这样做?到目前为止,我发现的所有示例都处理由简单分隔符解析的数据文件,这不是这里的情况.