是否有 Julia 包的 API

dav*_*der 6 api julia

大家好,我是一名老 Java/Haskell/Cobol 程序员。Julia 有许多很棒的功能,但我在我认为的基础知识上遇到了困难。特别是如何找到许多包中的内容(通量、绘图、微分方程等)。

  1. 我尝试过 VSCode 和 Jupiter Notebook 以及 Julia REPL,但没有找到在编写程序时提取这些重要信息的方法。
  2. 我也未能在网上找到信息,而这些信息却很少分布在每个包的教程中。

是否有“cheetsheet”或“summary”或类似java的API?

cbk*_*cbk 12

对于基础知识,我特别推荐两个“备忘单”

\n\n

然而,包生态系统过于多样化,任何备忘单都无法涵盖所有​​有用的包,因此对于单个包,我会推荐一些内置于该语言中的技巧:

\n
    \n
  • REPL 中的制表符完成。键入PackageName.<tab><tab>将打印 命名空间中的所有内容PackageName,例如:
  • \n
\n
julia> using Statistics\n\njulia> Statistics.\n\n_conj               _vmean               covm                 quantile!\n_getnobs            centralize_sumabs2   covzm                range_varm\n_mean               centralize_sumabs2!  eval                 realXcY\n_mean_promote       centralizedabs2fun   include              sqrt!\n_median             clampcor             mean                 std\n_quantile           cor                  mean!                stdm\n_quantilesort!      corm                 median               unscaled_covzm\n_std                corzm                median!              var\n_var                cov                  middle               varm\n_varm               cov2cor!             quantile             varm!\n
Run Code Online (Sandbox Code Playgroud)\n

请注意,由于这会打印包中的所有内容,因此其中包括可能不适合一般用途的功能。按照一般惯例,任何以下划线开头的函数_都不适合公共使用。

\n
    \n
  • 该函数 -- 将为您提供给定包导出的names所有函数的列表(因此比仅键入 更具选择性)。这实际上是任何给定 Julia 包的公共 API:PackageName.<tab><tab>
  • \n
\n
julia> using Statistics\n\njulia> names(Statistics)\n14-element Vector{Symbol}:\n :Statistics\n :cor\n :cov\n :mean\n :mean!\n :median\n :median!\n :middle\n :quantile\n :quantile!\n :std\n :stdm\n :var\n :varm\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • ?一旦您发现一个看起来很有前途的功能,只需在 REPL 提示符下键入即可访问内置帮助:
  • \n
\n
help?> cov\nsearch: cov convert StackOverflowError CUSOLVER has_cusolvermg code_llvm @code_llvm cudaconvert\n\n  cov(x::AbstractVector; corrected::Bool=true)\n\n  Compute the variance of the vector x. If corrected is true (the default) then the sum is scaled with\n  n-1, whereas the sum is scaled with n if corrected is false where n = length(x).\n\n  \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n\n  cov(X::AbstractMatrix; dims::Int=1, corrected::Bool=true)\n\n  Compute the covariance matrix of the matrix X along the dimension dims. If corrected is true (the\n  default) then the sum is scaled with n-1, whereas the sum is scaled with n if corrected is false\n  where n = size(X, dims).\n  \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n...\n...\n...\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • methodswith函数 -- 将为您提供可以对给定对象进行操作的所有函数的列表Type
  • \n
\n
julia> using LinearAlgebra, SparseArrays\n\njulia> methodswith(SparseMatrixCSC)\n\n[1] sizehint!(S::SparseMatrixCSC, n::Integer) in SparseArrays\n[2] cov(X::SparseMatrixCSC; dims, corrected) in Statistics\n[3] \\(L::SuiteSparse.CHOLMOD.Factor, B::SparseMatrixCSC) in SuiteSparse.CHOLMOD \n[4] lu(A::SparseMatrixCSC; check) in SuiteSparse.UMFPACK a\n[5] lu!(F::SuiteSparse.UMFPACK.UmfpackLU, A::SparseMatrixCSC; check) in SuiteSparse.UMFPACK\n[6] qr(A::SparseMatrixCSC; tol) in SuiteSparse.SPQR \n[7] rank(S::SparseMatrixCSC) in SuiteSparse.SPQR\n...\n...\n...\n
Run Code Online (Sandbox Code Playgroud)\n\n

最后,为了了解 stdlib 之外的包生态系统中还有哪些类型的包,我建议加入几个 Julia 社区论坛之一,例如discourseslackzulip

\n

  • 您可能还想添加一行关于 juliahub 在所有包中搜索函数的能力。 (2认同)