GitHub 的 Actions 功能最近开始允许用户生成徽章,以展示其测试的状态。例如,如果我有一组测试从名为 的文件在我的存储库的 dev 分支上运行.github/test_dev.yml,我可以通过添加到/badge.svg测试 URL 的末尾来访问该构建的状态。
https://github.com/<username>/<repo_name>/actions/workflows/test_dev.yml/badge.svg
Run Code Online (Sandbox Code Playgroud)
从让您的项目自述文件保持最新的项目状态的角度来看,这非常好,但下一个合乎逻辑的步骤是添加指向最新测试结果的徽章的链接。
不幸的是,即使您可以按如下方式访问特定操作的所有测试:
https://github.com/<username>/<repo_name>/actions/workflows/test_dev.yml
Run Code Online (Sandbox Code Playgroud)
测试运行本身似乎是在一个唯一的ID后面actions/runs/。
https://github.com/<username>/<repo_name>/actions/runs/1234567890
Run Code Online (Sandbox Code Playgroud)
有没有办法构造一个只指向最新测试的 URL?就像是:
https://github.com/<username>/<repo_name>/actions/workflows/test_dev.yml?result=latest
Run Code Online (Sandbox Code Playgroud)
我翻阅了 GitHub 的文档,但尽管有一些关于生成这些徽章 SVG 的文档,但我找不到任何有关直接链接到实际生成该 SVG 的操作的信息。
Jupyter Notebook(和 Jupyter Lab)附带了一个非常方便且交互式的 JSON 格式化程序。它对于让用户浏览非常深的字典而不用大量信息淹没输出单元非常有用。通常,如果我们有一个名为 的字典my_dict,您可以通过以下方式将其内容整齐地打印到输出单元格:
from IPython.display import display, JSON
display(JSON(my_dict))
Run Code Online (Sandbox Code Playgroud)
然后,用户可以与其交互以打开/关闭不同的部分。
问题是,如果您采用这种方法,它似乎无法在 GitHub 的 Web 浏览器上正确呈现。在它的位置,你将得到:
<IPython.core.display.JSON object>
有什么办法可以让我有一个像这样的 JSON 查看器,既可以在本地 JupyterLab 实例上运行,也可以在 GitHub 的网站上运行?或者我是否被迫用数百行 JSON 淹没输出单元?
如何使用 ISO Fortran Env 的内在函数以 Fortran 2008 惯用的方式设置函数的返回 KIND 值?
通常在主程序中,我可以只使用 ISO Fortran 内在函数,如下所示:
program name here
use iso_fortran_env
implicit none
integer, parameter :: double=REAL64
real(kind=double) :: some_variable
end program name here
Run Code Online (Sandbox Code Playgroud)
但是似乎没有一种方便的方法可以将这些内在函数用于外部函数,因为 REAL64 和 double 都只能在上面的 main 函数中定义。尝试在 main 中定义函数的 KIND 如下:
program name here
use iso_fortran_env
implicit none
integer, parameter :: double=REAL64
real(kind=double) :: some_function
! Do stuff
end program name here
real function some_function()
! Do stuff
end some_function
Run Code Online (Sandbox Code Playgroud)
至少在我的系统上,会引发类型不匹配错误(double 被定义为 KIND=8,并且在我的系统上默认实数被定义为 KIND=4)。我总是可以只使用real(kind=8) function some_function(),但为了可移植性我不想这样做。另外,在一个地方使用 …
从itertools.combinations()获得的项目顺序是否确定?
我目前正在编写一个脚本,它使用itertools.combinations产生过多的对象,足够大以至于我无法将它全部保留在内存中.对于每个组合,都有一个函数返回一个存储在numpy数组中的值(因为它们具有相当的内存效率).我只有足够的内存来存储所有这些花车.
然后我迭代那些浮点数,如果它是一个感兴趣的索引,我再次使用计数器变量运行itertools.combinations来访问产生该结果的组合(只需要几秒钟).
我用各种较小的数据集测试了这个,我有足够的内存,并且在这些情况下条目都是相同的,但我担心这不是一个"安全"的方法来做我想要的.
在Python3中,不幸的决定是删除相对导入的功能。我目前正在现代化大量使用此功能的大量Python2代码。
因此,现在,我的代码具有以下效果:
import other_function
import another_class_file
...
foo = other_function.calculate_foo() + other_function.constant
bar = another_class_file.Bar(foo)
Run Code Online (Sandbox Code Playgroud)
据我所知,在Python3中执行此操作的“正确”方法是:
from other_function import foo as calculate_foo
from other_function import constant
from another_class_file import Bar
....
foo = calculate_foo() + constant
bar = Bar(foo)
Run Code Online (Sandbox Code Playgroud)
但是,这种方式非常肮脏:不是总知道确切的函数或类的来源,而是全都放在了顶层,而了解某物的来源的唯一方法是查看导入语句的列表。顶端。总的来说,代码变得更加模棱两可。显式胜于隐式。
有什么办法可以实现相同的表示法,类似于from other_function import foo as other_function.calculate_foo?我不想手动将这些名称命名为匈牙利风格。
python ×3
github ×2
fortran ×1
fortran2008 ×1
function ×1
ipython ×1
jupyter-lab ×1
python-3.x ×1
url ×1