# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=470

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 471

---

## [Current best practises on dealing with optional dependencies](https://discourse.julialang.org/t/current-best-practises-on-dealing-with-optional-dependencies/78015)

<div class="topic-metadata">

**Author:** [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Replies:** 3\
**Last updated:** [March 20, 2022, 7:38pm UTC](https://discourse.julialang.org/t/current-best-practises-on-dealing-with-optional-dependencies/78015 "2022-03-20T19:38:13Z")

</div>

Say I’ve written up a package to compute Foo and now I’d like to add support to write and read Foo to HDF5 or to plot Foo. May be I’d like to plug a DifferentialEquations.jl solution into Foo. What is the current recomme…

---

## [Common legend for subplots](https://discourse.julialang.org/t/common-legend-for-subplots/78079)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [March 20, 2022, 7:30pm UTC](https://discourse.julialang.org/t/common-legend-for-subplots/78079 "2022-03-20T19:30:30Z")

</div>

Hi all, I have a follow up question to this ongoing issue about using a common legend across subplots. In my use case, a vector of plots with an unknown length are combined into a grid of subplots. Subplots do not nece…

---

## [Equivalent to plt.add\_axis in Plots.jl?](https://discourse.julialang.org/t/equivalent-to-plt-add-axis-in-plots-jl/78166)

<div class="topic-metadata">

**Author:** [@SamuelJosephs](https://discourse.julialang.org/u/SamuelJosephs)\
**Replies:** 0\
**Last updated:** [March 20, 2022, 3:37pm UTC](https://discourse.julialang.org/t/equivalent-to-plt-add-axis-in-plots-jl/78166 "2022-03-20T15:37:25Z")

</div>

I would like to have some plots with a subplot directly underneath, such as here: How would I go about positioning subplots to get two plots stacked on top of each other?

---

## [Suppression of Info messages on package load](https://discourse.julialang.org/t/suppression-of-info-messages-on-package-load/78169)

<div class="topic-metadata">

**Author:** [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Replies:** 0\
**Last updated:** [March 20, 2022, 5:03pm UTC](https://discourse.julialang.org/t/suppression-of-info-messages-on-package-load/78169 "2022-03-20T17:03:45Z")

</div>

I’m having trouble suppressing Info messages from an imported module—in this case, the MatrixDepot module, which spits out a few lines when imported. At the REPL, the following does what I want: module foo using Loggi…

---

## [CI broken on nightly](https://discourse.julialang.org/t/ci-broken-on-nightly/78159)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 3\
**Last updated:** [March 20, 2022, 3:44pm UTC](https://discourse.julialang.org/t/ci-broken-on-nightly/78159 "2022-03-20T15:44:20Z")

</div>

I have the following code in my file CI.yml: jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event\_name }} runs-on: ${{ matrix.os }} timeout-minutes: 40 …

---

## [How to use 96 bits floats?](https://discourse.julialang.org/t/how-to-use-96-bits-floats/78155)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 4\
**Last updated:** [March 20, 2022, 12:29pm UTC](https://discourse.julialang.org/t/how-to-use-96-bits-floats/78155 "2022-03-20T12:29:01Z")

</div>

I am solving some linear systems with ill-conditioned sparse matrices. Using Float64 sometimes the solver returns “Singular matrix”. I would like to increase the number of bits for the floating-point numbers in the spar…

---

## [Julia - How to plot a histogram with density as the vertical axis (中怎么绘制密度为纵轴的直方图)](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149)

<div class="topic-metadata">

**Author:** [@Yanjj1](https://discourse.julialang.org/u/Yanjj1)\
**Replies:** 2\
**Last updated:** [March 20, 2022, 3:56am UTC](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149 "2022-03-20T03:56:03Z")

</div>

1、julia怎么绘制直方图，纵轴为密度，然后拟合密度曲线 2、julia怎么绘制正态分布曲线？ 3.或者julia对于r里的ggplot的…density…会无法识别要怎么修改？以下是我的r代码 ggplot(data, aes\_string(x=“V5”)) + geom\_histogram(aes(y=…density…), # 这一步很重要,使用density代替y轴 binwidth=1, colour=…

---

## [\`log\` performance regression and JET failures](https://discourse.julialang.org/t/log-performance-regression-and-jet-failures/78146)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 3\
**Last updated:** [March 20, 2022, 12:33am UTC](https://discourse.julialang.org/t/log-performance-regression-and-jet-failures/78146 "2022-03-20T00:33:32Z")

</div>

Hi, I’m seeing some surprising results for log in 1.8.0-beta1. First, 1.7: julia\> versioninfo() Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86\_64-pc-linux-gnu) CPU: Intel(…

---

## [How to acces the array element of symbolic array](https://discourse.julialang.org/t/how-to-acces-the-array-element-of-symbolic-array/78135)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 0\
**Last updated:** [March 19, 2022, 4:07pm UTC](https://discourse.julialang.org/t/how-to-acces-the-array-element-of-symbolic-array/78135 "2022-03-19T16:07:56Z")

</div>

Hi All, I want to convert matlab code to julia. is there a way to access elements of symbolic expression. function \[xqq,xq,wq\]=SetIntoptimal1D(n) clc #clear all; syms y # Input n: Quad pt rule m=n-1; P=sym('a',\[1,n\])…

---

## [Type instability with Union or heterogenous array/tuple](https://discourse.julialang.org/t/type-instability-with-union-or-heterogenous-array-tuple/78122)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 8\
**Last updated:** [March 19, 2022, 3:23pm UTC](https://discourse.julialang.org/t/type-instability-with-union-or-heterogenous-array-tuple/78122 "2022-03-19T15:23:31Z")

</div>

Hey Julianners, I just cannot figure out how to make type stable code in case when we have a “sort of” heterogeneous array or tuple and we randomly pick an element. I did this minimal example. hn(qq) = begin local r …

---

## [Imfilter for 3d array](https://discourse.julialang.org/t/imfilter-for-3d-array/78118)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [March 19, 2022, 2:55pm UTC](https://discourse.julialang.org/t/imfilter-for-3d-array/78118 "2022-03-19T14:55:41Z")

</div>

I am doing sdata = imfilter(deepcopy(tdata), Kernel.gaussian(3), Inner()) where tdata is a 3d array. It appears that the smoothing is being done by considering separately 2d slices of the image. Am I missing something…

---

## [Why is \`collect()\` faster than a for loop in this numerical scheme? (corrected!)](https://discourse.julialang.org/t/why-is-collect-faster-than-a-for-loop-in-this-numerical-scheme-corrected/78003)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 25\
**Last updated:** [March 19, 2022, 10:33am UTC](https://discourse.julialang.org/t/why-is-collect-faster-than-a-for-loop-in-this-numerical-scheme-corrected/78003 "2022-03-19T10:33:54Z")

</div>

Consider a toy algorithm that finds the maximum of a vector, then removes it and alters the other entries of the vector in a way that depends on whether they are located at a lower or higher index. (N.B. I posted a simp…

---

## [Why the variable's value does not change?](https://discourse.julialang.org/t/why-the-variables-value-does-not-change/78120)

<div class="topic-metadata">

**Author:** [@PoleZhang](https://discourse.julialang.org/u/PoleZhang)\
**Replies:** 2\
**Last updated:** [March 19, 2022, 9:01am UTC](https://discourse.julialang.org/t/why-the-variables-value-does-not-change/78120 "2022-03-19T09:01:42Z")

</div>

a = 200000 function TestAdd(a::Ref{Int64}) println("Before add $(a\[ \])") a\[\]+= 10 println("After add $(a\[\])") end TestAdd(Ref(a)) println(a) Result as below : Before add 200000 After add 200010 200000

---

## [Classical fit Rectangles in Rectangles problematic](https://discourse.julialang.org/t/classical-fit-rectangles-in-rectangles-problematic/76902)

<div class="topic-metadata">

**Author:** [@Hirnfolter1](https://discourse.julialang.org/u/Hirnfolter1)\
**Replies:** 1\
**Last updated:** [March 19, 2022, 7:17am UTC](https://discourse.julialang.org/t/classical-fit-rectangles-in-rectangles-problematic/76902 "2022-03-19T07:17:18Z")

</div>

Hello, I have the following problem and searching for a solution or good Pkg which helps with the problem. I have n-Rectangles of different size and each rectangle has a Value, independent from the size. I also have o…

---

## [Create any functions with a macro, the functions can call each other](https://discourse.julialang.org/t/create-any-functions-with-a-macro-the-functions-can-call-each-other/78113)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 2\
**Last updated:** [March 19, 2022, 6:09am UTC](https://discourse.julialang.org/t/create-any-functions-with-a-macro-the-functions-can-call-each-other/78113 "2022-03-19T06:09:04Z")

</div>

hello, i need to create any functions with a macro, the functions can call each other. What am I doing wrong ? macro macr(ClassName::Symbol) local Class = @eval $ClassName return esc(quote foo(::Type{$Cl…

---

## [Function not defined when occurring in else-clause inside of another function](https://discourse.julialang.org/t/function-not-defined-when-occurring-in-else-clause-inside-of-another-function/78106)

<div class="topic-metadata">

**Author:** [@Geometh](https://discourse.julialang.org/u/Geometh)\
**Replies:** 2\
**Last updated:** [March 19, 2022, 5:24am UTC](https://discourse.julialang.org/t/function-not-defined-when-occurring-in-else-clause-inside-of-another-function/78106 "2022-03-19T05:24:42Z")

</div>

Hi there, I ran into some weird behavior that I don’t understand. When having two possible function declarations inside an if-else-statement which is wrapped in some outer function, the assignment inside the else-clause…

---

## [Trying to add kernels for Gaussian Process](https://discourse.julialang.org/t/trying-to-add-kernels-for-gaussian-process/78117)

<div class="topic-metadata">

**Author:** [@mirror63](https://discourse.julialang.org/u/mirror63)\
**Replies:** 0\
**Last updated:** [March 19, 2022, 1:54am UTC](https://discourse.julialang.org/t/trying-to-add-kernels-for-gaussian-process/78117 "2022-03-19T01:54:40Z")

</div>

I want to add two kernels for my Gaussian Process, I am using GaussianProcesses.jl . Can somebody give me an example of adding two kernels for a GP. The two kernels I am trying to add are: Periodic + Noise using Gauss…

---

## [Can this be made faster?](https://discourse.julialang.org/t/can-this-be-made-faster/78064)

<div class="topic-metadata">

**Author:** [@r0b0ty](https://discourse.julialang.org/u/r0b0ty)\
**Replies:** 5\
**Last updated:** [March 19, 2022, 1:00am UTC](https://discourse.julialang.org/t/can-this-be-made-faster/78064 "2022-03-19T01:00:39Z")

</div>

I have two DataFrames. The size of the first is (7390, 2), represented below by a small (3, 2) array. The size of the second is quite a bit larger, at (482244, 8), represented below by a larger (7, 4) array. I need to…

---

## [Struct not recognized as the same struct in a different script](https://discourse.julialang.org/t/struct-not-recognized-as-the-same-struct-in-a-different-script/78100)

<div class="topic-metadata">

**Author:** [@Kevin\_Shen1](https://discourse.julialang.org/u/Kevin_Shen1)\
**Replies:** 1\
**Last updated:** [March 19, 2022, 12:57am UTC](https://discourse.julialang.org/t/struct-not-recognized-as-the-same-struct-in-a-different-script/78100 "2022-03-19T00:57:54Z")

</div>

I have a struct called HyperState I’m persisting with JLD2.save() in a Julia script. However when I try to load it back in a Pluto notebook, I get the warning: type Main.HyperState does not exist in workspace; reconstruc…

---

## [How to create a struct that contains an SVector of structs?](https://discourse.julialang.org/t/how-to-create-a-struct-that-contains-an-svector-of-structs/78110)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [March 19, 2022, 12:00am UTC](https://discourse.julialang.org/t/how-to-create-a-struct-that-contains-an-svector-of-structs/78110 "2022-03-19T00:00:10Z")

</div>

The following code does not work: using StaticArrays, Parameters import Base.zero const SEGMENTS = 6 # struct, defining the physical parameters of one spring @with\_kw mutable struct Spring{I, S} p1::I = 1 …

---

## [Underline numbers in matrix](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 2\
**Last updated:** [March 18, 2022, 10:55pm UTC](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112 "2022-03-18T22:55:22Z")

</div>

julia\> Matrix(reshape(1:100,10,10)) 10×10 Matrix{Int64}: 1 11 21 31 41 51 61 71 81 91 2 12 22 32 42 52 62 72 82 92 3 13 23 33 43 53 63 73 83 93 4 14 24 34 44 54 64 74 84 94…

---

## [How to include my module file as a package?](https://discourse.julialang.org/t/how-to-include-my-module-file-as-a-package/75682)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 24\
**Last updated:** [March 18, 2022, 9:24pm UTC](https://discourse.julialang.org/t/how-to-include-my-module-file-as-a-package/75682 "2022-03-18T21:24:10Z")

</div>

I have some user-defined structures and I put them in Module file. module name\_module # here all structures end I want to import my structures from my module as below (as a package), however, I have an error. Any idea …

---

## [Question on Type Inference with Anonymous Functions and Broadcast](https://discourse.julialang.org/t/question-on-type-inference-with-anonymous-functions-and-broadcast/78102)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 3\
**Last updated:** [March 18, 2022, 7:42pm UTC](https://discourse.julialang.org/t/question-on-type-inference-with-anonymous-functions-and-broadcast/78102 "2022-03-18T19:42:55Z")

</div>

Hello! I have a question. Consider this function. f(x) = exp(2 \* x) x = range(0, 1, 2^5) If I want to pass x into it I would do f.(x) and if I do @code\_warntype I can see everything is inferred. Body::Vector{Float64}…

---

## [Parallel deployment in DataFrames and CSV operations](https://discourse.julialang.org/t/parallel-deployment-in-dataframes-and-csv-operations/78070)

<div class="topic-metadata">

**Author:** [@AlanAylmer](https://discourse.julialang.org/u/AlanAylmer)\
**Replies:** 6\
**Last updated:** [March 18, 2022, 4:41pm UTC](https://discourse.julialang.org/t/parallel-deployment-in-dataframes-and-csv-operations/78070 "2022-03-18T16:41:39Z")

</div>

Hi. Using Julia happily for 3 years. Just checking before I do some potentially destructive file handling. I have huge amounts of monthly data and I want to clean-reformat it and I have a working code and an 8 core lapt…

---

## [Buffer in running external program in loops](https://discourse.julialang.org/t/buffer-in-running-external-program-in-loops/78087)

<div class="topic-metadata">

**Author:** [@ValentinChb](https://discourse.julialang.org/u/ValentinChb)\
**Replies:** 24\
**Last updated:** [March 18, 2022, 3:39pm UTC](https://discourse.julialang.org/t/buffer-in-running-external-program-in-loops/78087 "2022-03-18T15:39:37Z")

</div>

I’d like to run system calls sequentially in a for loop, waiting for last call to complete before running the next one. The run(command) call is nested in a function (run\_system\_call in the example under) which is part …

---

## [How to reset GPU after launch failure](https://discourse.julialang.org/t/how-to-reset-gpu-after-launch-failure/28768)

<div class="topic-metadata">

**Author:** [@Michael\_Benton](https://discourse.julialang.org/u/Michael_Benton)\
**Replies:** 8\
**Last updated:** [March 18, 2022, 1:49pm UTC](https://discourse.julialang.org/t/how-to-reset-gpu-after-launch-failure/28768 "2022-03-18T13:49:16Z")

</div>

If I write a kernel that fails for whatever reason, julia becomes unable to use the GPU for the remainder of the session example : julia\>cu(\[1.,2.\]) CUDA error: unspecified launch failure (code #719, ERROR\_LAUNCH\_FAIL…

---

## [Simple method for getting indices of a sub array along top, bottom or side of larger matrix A?](https://discourse.julialang.org/t/simple-method-for-getting-indices-of-a-sub-array-along-top-bottom-or-side-of-larger-matrix-a/77977)

<div class="topic-metadata">

**Author:** [@kurt](https://discourse.julialang.org/u/kurt)\
**Replies:** 2\
**Last updated:** [March 18, 2022, 12:55pm UTC](https://discourse.julialang.org/t/simple-method-for-getting-indices-of-a-sub-array-along-top-bottom-or-side-of-larger-matrix-a/77977 "2022-03-18T12:55:59Z")

</div>

I am trying to figure out how to get a sub array out of larger Array, A (MxN). The question is not about whether to use slice or view. I do not need to change the original matrix A, so I will be using slice. I need to ge…

---

## [Writing an exam paper with Julia and Jupyter Lab](https://discourse.julialang.org/t/writing-an-exam-paper-with-julia-and-jupyter-lab/78082)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 0\
**Last updated:** [March 18, 2022, 12:42pm UTC](https://discourse.julialang.org/t/writing-an-exam-paper-with-julia-and-jupyter-lab/78082 "2022-03-18T12:42:30Z")

</div>

Writing an exam paper with Julia and Jupyter Lab I just taught Linear Algebra, which means I need to give exams with a lot of questions about computations. I would like to have the numbers in this problems to be random, …

---

## [Unable to add registries through proxy on Julia 1.7.1, Julia 1.7.0](https://discourse.julialang.org/t/unable-to-add-registries-through-proxy-on-julia-1-7-1-julia-1-7-0/74919)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 10\
**Last updated:** [March 18, 2022, 11:32am UTC](https://discourse.julialang.org/t/unable-to-add-registries-through-proxy-on-julia-1-7-1-julia-1-7-0/74919 "2022-03-18T11:32:08Z")

</div>

I have not managed to run Julia 1.7.1, Julia 1.7.0. Each new version of Julia repeats this problem to me. I have repeated the solutions for the previous versions, without success !!! HELP ME!!! \_ \_ …

---

## [Markdown inconsistency: PlutoUI, latexifications](https://discourse.julialang.org/t/markdown-inconsistency-plutoui-latexifications/78076)

<div class="topic-metadata">

**Author:** [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Replies:** 1\
**Last updated:** [March 18, 2022, 11:05am UTC](https://discourse.julialang.org/t/markdown-inconsistency-plutoui-latexifications/78076 "2022-03-18T11:05:02Z")

</div>

I’ve previously solved the issue of interpolating latexified expressions in Pluto by using Markdown.parse() rather than md"". But rather unsatisfyingly, the opposite compatibilty constraints apply to PlutoUI elements: u…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=469)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=471)
