你好,我是一名老Java/Haskell/Cobol程序员。Julia有许多出色的功能,但我正在努力学习我认为的基础知识。特别是如何查找众多软件包(如Flux、Plots、DifferentialEquations等)中的内容。
- 我已经尝试过VSCode、Jupyter笔记本和Julia REPL,但没有找到在编写程序时提取这些基本信息的方法。
- 我也未能在网络上找到有关此信息的摘要,只能在每个软件包的教程中零散地获取。
是否有"cheetsheet"或类似于Java API的"概述"文档?
你好,我是一名老Java/Haskell/Cobol程序员。Julia有许多出色的功能,但我正在努力学习我认为的基础知识。特别是如何查找众多软件包(如Flux、Plots、DifferentialEquations等)中的内容。
是否有"cheetsheet"或类似于Java API的"概述"文档?
对于基础知识,我特别推荐两份“速查表”
然而,软件包生态系统过于多样化,任何速查表都无法覆盖所有有用的软件包,因此针对单个软件包,我建议使用语言内置的一些技巧:
PackageName.<tab><tab>
将打印出PackageName
命名空间中的所有内容,例如:julia> using Statistics
julia> Statistics.
_conj _vmean covm quantile!
_getnobs centralize_sumabs2 covzm range_varm
_mean centralize_sumabs2! eval realXcY
_mean_promote centralizedabs2fun include sqrt!
_median clampcor mean std
_quantile cor mean! stdm
_quantilesort! corm median unscaled_covzm
_std corzm median! var
_var cov middle varm
_varm cov2cor! quantile varm!
请注意,由于这打印包中的所有内容,因此包括可能不适用于一般用途的函数。按照惯例,任何以下划线 _
开头的函数均不适用于公共使用。
names
函数-- 可以列出给定 Julia 包所导出的所有函数的列表(因此比只键入PackageName.<tab><tab>
更为选择性)。这实际上是任何给定 Julia 包的公共 API:julia> using Statistics
julia> names(Statistics)
14-element Vector{Symbol}:
:Statistics
:cor
:cov
:mean
:mean!
:median
:median!
:middle
:quantile
:quantile!
:std
:stdm
:var
:varm
?
访问内置帮助:help?> cov
search: cov convert StackOverflowError CUSOLVER has_cusolvermg code_llvm @code_llvm cudaconvert
cov(x::AbstractVector; corrected::Bool=true)
Compute the variance of the vector x. If corrected is true (the default) then the sum is scaled with
n-1, whereas the sum is scaled with n if corrected is false where n = length(x).
────────────────────────────────────────────────────────────────────────────────────────────────────
cov(X::AbstractMatrix; dims::Int=1, corrected::Bool=true)
Compute the covariance matrix of the matrix X along the dimension dims. If corrected is true (the
default) then the sum is scaled with n-1, whereas the sum is scaled with n if corrected is false
where n = size(X, dims).
────────────────────────────────────────────────────────────────────────────────────────────────────
...
...
...
methodswith
函数 -- 可以给你一个列表,列出所有可以在指定Type
的对象上操作的函数:julia> using LinearAlgebra, SparseArrays
julia> methodswith(SparseMatrixCSC)
[1] sizehint!(S::SparseMatrixCSC, n::Integer) in SparseArrays
[2] cov(X::SparseMatrixCSC; dims, corrected) in Statistics
[3] \(L::SuiteSparse.CHOLMOD.Factor, B::SparseMatrixCSC) in SuiteSparse.CHOLMOD
[4] lu(A::SparseMatrixCSC; check) in SuiteSparse.UMFPACK a
[5] lu!(F::SuiteSparse.UMFPACK.UmfpackLU, A::SparseMatrixCSC; check) in SuiteSparse.UMFPACK
[6] qr(A::SparseMatrixCSC; tol) in SuiteSparse.SPQR
[7] rank(S::SparseMatrixCSC) in SuiteSparse.SPQR
...
...
...
最后,为了了解标准库之外的软件包生态系统中有哪些软件包,我建议加入几个 Julia 社区论坛之一,如 discourse、slack 或 zulip。
apropos
,可以通过关键字搜索函数(其中也包括已加载的包)。 - Alex338207