# General Usage

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

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

**Page:** 540

---

## [Automatic differentiation performance & computing derivatives of only a subset of the arguments](https://discourse.julialang.org/t/automatic-differentiation-performance-computing-derivatives-of-only-a-subset-of-the-arguments/69074)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 6\
**Last updated:** [October 2, 2021, 8:46pm UTC](https://discourse.julialang.org/t/automatic-differentiation-performance-computing-derivatives-of-only-a-subset-of-the-arguments/69074 "2021-10-02T20:46:41Z")

</div>

Here is a minimal working example const x = -10:10 f(m) = exp.(-1.5 .\* (x .- m).^2) function rs(d,xs) d0 = f(xs) d .- sum(d .\* d0) / sum(d0 .\* d0) .\* d0 end drs(d,xs) = (rs(d,xs + 1e-6) .- rs(d,xs)) / 1e-6 drs\_aut…

---

## [How to best program this function with cases?](https://discourse.julialang.org/t/how-to-best-program-this-function-with-cases/68703)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 6\
**Last updated:** [October 2, 2021, 7:37pm UTC](https://discourse.julialang.org/t/how-to-best-program-this-function-with-cases/68703 "2021-10-02T19:37:09Z")

</div>

I have this function that depends on cases i. I programmed it this way, but I am wondering if there is a better way of achieving the same result and with better performance. using ComponentArrays θ = ComponentArray(one…

---

## [Clustering using matrix decomp code performance tips](https://discourse.julialang.org/t/clustering-using-matrix-decomp-code-performance-tips/68838)

<div class="topic-metadata">

**Author:** [@spinkney](https://discourse.julialang.org/u/spinkney)\
**Replies:** 5\
**Last updated:** [October 2, 2021, 7:05pm UTC](https://discourse.julialang.org/t/clustering-using-matrix-decomp-code-performance-tips/68838 "2021-10-02T19:05:18Z")

</div>

Hi Julians, I’ve ported this matlab code from Clustering by low-rank doubly stochastic matrix decomposition to Julia. But it’s much too slow for my application. I’m still green to Julia so posting here to see if there’…

---

## [Why is there difference between time and @time?](https://discourse.julialang.org/t/why-is-there-difference-between-time-and-time/69094)

<div class="topic-metadata">

**Author:** [@zhaoli-IHEP](https://discourse.julialang.org/u/zhaoli-IHEP)\
**Replies:** 8\
**Last updated:** [October 2, 2021, 1:57pm UTC](https://discourse.julialang.org/t/why-is-there-difference-between-time-and-time/69094 "2021-10-02T13:57:23Z")

</div>

In a simple script using SymEngine function test() @vars q1, q2 return q1+q2 end # function test @time test() we measure the time by using @time, and then we check the timing in the script run like \[ ~/works/…

---

## [Faster squared euclidean distance calculation](https://discourse.julialang.org/t/faster-squared-euclidean-distance-calculation/68969)

<div class="topic-metadata">

**Author:** [@jroon](https://discourse.julialang.org/u/jroon)\
**Replies:** 11\
**Last updated:** [October 2, 2021, 12:59pm UTC](https://discourse.julialang.org/t/faster-squared-euclidean-distance-calculation/68969 "2021-10-02T12:59:34Z")

</div>

Hi all. Trying to speed up a small function that multiplies an array by vector before doing a distance calculation. A small reprex: using BenchmarkTools using Distances using Tullio function calc1(r::Array{Float64, 1}…

---

## [Weighted sampling algorithms not yet shipped?](https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111)

<div class="topic-metadata">

**Author:** [@Naba7](https://discourse.julialang.org/u/Naba7)\
**Replies:** 1\
**Last updated:** [October 2, 2021, 12:40pm UTC](https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111 "2021-10-02T12:40:39Z")

</div>

Why direct\_sample!, knuths\_sample!, alias\_sample or any of the other Weighted sampling algorithms say they are not defined? Are those functions not yet shipped? direct\_sample!(Random.GLOBAL\_RNG, rand(50), Weights(rand(5…

---

## [Some clarification on \`@inbounds\`](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076)

<div class="topic-metadata">

**Author:** [@markmbaum](https://discourse.julialang.org/u/markmbaum)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 9:51pm UTC](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076 "2021-10-01T21:51:32Z")

</div>

I know that @inbounds can be applied before a statement like x\[i\] = y and it will elide the bounds check for the setindex! call on x. I’m a little confused about where else @inbounds can be applied, though. If I write …

---

## [Mixed partials](https://discourse.julialang.org/t/mixed-partials/69068)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 1\
**Last updated:** [October 1, 2021, 9:29pm UTC](https://discourse.julialang.org/t/mixed-partials/69068 "2021-10-01T21:29:11Z")

</div>

Suppose that I have a scalar function of multiple variables, e.g., z = f(x,y) How can I compute mixed partials using ForwardDiff? E.g., suppose that I want d^2f/dxdy The case for the hessian, it is clear, e.g., d^2f/…

---

## [Strange symbols show up on using LaTeX tables in Pluto Notebook](https://discourse.julialang.org/t/strange-symbols-show-up-on-using-latex-tables-in-pluto-notebook/69050)

<div class="topic-metadata">

**Author:** [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 7:46pm UTC](https://discourse.julialang.org/t/strange-symbols-show-up-on-using-latex-tables-in-pluto-notebook/69050 "2021-10-01T19:46:23Z")

</div>

Hi. I’m seen strange symbols on LaTeX tables when they render in Pluto Notebooks. Its just a temporary bug or could I’m making some mistakes? I’m using Chrome Browser. In anex a print from notebook and the code. Best …

---

## [Instability diffeq](https://discourse.julialang.org/t/instability-diffeq/69062)

<div class="topic-metadata">

**Author:** [@Jorge\_Silva](https://discourse.julialang.org/u/Jorge_Silva)\
**Replies:** 1\
**Last updated:** [October 1, 2021, 6:09pm UTC](https://discourse.julialang.org/t/instability-diffeq/69062 "2021-10-01T18:09:26Z")

</div>

I have a system with a dependent mass matrix. It always return me some mensage of instability. Is it an intrisic characteristic of the system? Any thing I can do about? using DifferentialEquations alpha=0.105 …

---

## [Julia embedding in a dylib](https://discourse.julialang.org/t/julia-embedding-in-a-dylib/68830)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 3\
**Last updated:** [October 1, 2021, 4:12pm UTC](https://discourse.julialang.org/t/julia-embedding-in-a-dylib/68830 "2021-10-01T16:12:37Z")

</div>

I’m testing a specific case of Embedding Julia · The Julia Language on MacOS. I need to call Julia from a dylib (dylib code in C++) that is called from Julia to pass input data and analyze the results. In other words: …

---

## [Transform counts to binary variable in DataFrame](https://discourse.julialang.org/t/transform-counts-to-binary-variable-in-dataframe/69044)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 5\
**Last updated:** [October 1, 2021, 3:55pm UTC](https://discourse.julialang.org/t/transform-counts-to-binary-variable-in-dataframe/69044 "2021-10-01T15:55:34Z")

</div>

I have a DataFrame containing counts of a binary variable (yes/no). I would like to code the counts as instances of 1 = yes and no = 0. Here is a simple example of the Dataframe with the same structure as my dataset: i…

---

## [How to use \`display\` in \`sprint\`?](https://discourse.julialang.org/t/how-to-use-display-in-sprint/69040)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [October 1, 2021, 2:42pm UTC](https://discourse.julialang.org/t/how-to-use-display-in-sprint/69040 "2021-10-01T14:42:42Z")

</div>

Hi all :slight\_smile: I want to do something like that to get the display string. julia\> display\_str = sprint(display, Dict(1:10 .=\> 1:10)) But it does not work. How would I do that?

---

## [Diagnosing rrule issues](https://discourse.julialang.org/t/diagnosing-rrule-issues/69036)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 8\
**Last updated:** [October 1, 2021, 2:24pm UTC](https://discourse.julialang.org/t/diagnosing-rrule-issues/69036 "2021-10-01T14:24:01Z")

</div>

I am using ChainRulesTestUtils to test an rrule for a function mulsafe I define below. The idea is that mulsafe(x,y) returns the product x .\* y, but giving a strong zero if x == 0 (even if y is Inf, or NaN). using Chain…

---

## [Change setting of --check-bounds in user code?](https://discourse.julialang.org/t/change-setting-of-check-bounds-in-user-code/69038)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 0\
**Last updated:** [October 1, 2021, 11:52am UTC](https://discourse.julialang.org/t/change-setting-of-check-bounds-in-user-code/69038 "2021-10-01T11:52:37Z")

</div>

I’m adding a ‘–debug’ flag to my code, so that users/developers can set an integer ‘debug level’ to run the code with. I’d like one of these levels to force bounds-checking, i.e. behave as if I’d started Julia with --che…

---

## [Package for arbitrary \`getindex\` function?](https://discourse.julialang.org/t/package-for-arbitrary-getindex-function/69034)

<div class="topic-metadata">

**Author:** [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Replies:** 5\
**Last updated:** [October 1, 2021, 10:08am UTC](https://discourse.julialang.org/t/package-for-arbitrary-getindex-function/69034 "2021-10-01T10:08:46Z")

</div>

Does anyone know if we have an array package that lets you specify an arbitrary getindex function? Implementing it is pretty trivial; aside from tests, this is a complete package: module ClosureArrays export ClosureArr…

---

## [How to see list of available Package Versions? (AKA how to downgrade because Turing crashes?)](https://discourse.julialang.org/t/how-to-see-list-of-available-package-versions-aka-how-to-downgrade-because-turing-crashes/69020)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 6\
**Last updated:** [October 1, 2021, 6:05am UTC](https://discourse.julialang.org/t/how-to-see-list-of-available-package-versions-aka-how-to-downgrade-because-turing-crashes/69020 "2021-10-01T06:05:06Z")

</div>

I installed the latest Turing and now I can’t “using Turing” because: julia\> using Turing ERROR: InitError: UndefVarError: Params not defined Stacktrace: \[1\] top-level scope @ none:1 \[2\] eval @ ./boot.jl:37…

---

## [@foreach item in vector](https://discourse.julialang.org/t/foreach-item-in-vector/69024)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 5:16am UTC](https://discourse.julialang.org/t/foreach-item-in-vector/69024 "2021-10-01T05:16:00Z")

</div>

I want to run a bit of code for each item in a vector, as if I’d typed it out multiple types. Not using a function or run-time loop. How can I do that? Similar to this but with no function: foreach(1:5) do x printl…

---

## [Cannot clone on julia 1.6.3](https://discourse.julialang.org/t/cannot-clone-on-julia-1-6-3/68757)

<div class="topic-metadata">

**Author:** [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Replies:** 2\
**Last updated:** [September 30, 2021, 7:28pm UTC](https://discourse.julialang.org/t/cannot-clone-on-julia-1-6-3/68757 "2021-09-30T19:28:43Z")

</div>

I’ve upgraded julia to 1.6.3 (own build), with libgit2 1.2.0, on linux. Seems like cloning fails: (@v1.6) pkg\> add Plots#master Cloning git-repo \`https://github.com/JuliaPlots/Plots.jl.git\` ERROR: ReadOnlyMemoryEr…

---

## [How to make a macro modify struct member?](https://discourse.julialang.org/t/how-to-make-a-macro-modify-struct-member/68991)

<div class="topic-metadata">

**Author:** [@droodman](https://discourse.julialang.org/u/droodman)\
**Replies:** 1\
**Last updated:** [September 30, 2021, 1:49pm UTC](https://discourse.julialang.org/t/how-to-make-a-macro-modify-struct-member/68991 "2021-09-30T13:49:54Z")

</div>

I am trying to write a macro that may generate an assignment statement to modify one of its arguments (more precisely, modify the object the argument binds to). That argument will be a member of a mutable struct; which m…

---

## [How to launch several run cmd in parallel](https://discourse.julialang.org/t/how-to-launch-several-run-cmd-in-parallel/68862)

<div class="topic-metadata">

**Author:** [@RCHG](https://discourse.julialang.org/u/RCHG)\
**Replies:** 4\
**Last updated:** [September 30, 2021, 1:37pm UTC](https://discourse.julialang.org/t/how-to-launch-several-run-cmd-in-parallel/68862 "2021-09-30T13:37:53Z")

</div>

Hello, My question is probably easy to solve, but I got confused by the several packages and proposals (@sync, @async, Distributed etc…). In the most simple case there is a script in Julia. This script has a loop that r…

---

## [Permission denied](https://discourse.julialang.org/t/permission-denied/68997)

<div class="topic-metadata">

**Author:** [@Axelle\_francx](https://discourse.julialang.org/u/Axelle_francx)\
**Replies:** 2\
**Last updated:** [September 30, 2021, 1:05pm UTC](https://discourse.julialang.org/t/permission-denied/68997 "2021-09-30T13:05:52Z")

</div>

https://docs.junolab.org/latest/man/installation/ I have followed the above steps but still get this error message. The link says that you have to change the julia path, which I did, but I still get an error message. Do…

---

## [Unable to use Zlib\_jll in julia 1.6 (Package Zlib\_jll does not have JLLWrappers in its dependencies)](https://discourse.julialang.org/t/unable-to-use-zlib-jll-in-julia-1-6-package-zlib-jll-does-not-have-jllwrappers-in-its-dependencies/68975)

<div class="topic-metadata">

**Author:** [@bluesmoon](https://discourse.julialang.org/u/bluesmoon)\
**Replies:** 3\
**Last updated:** [September 30, 2021, 12:20pm UTC](https://discourse.julialang.org/t/unable-to-use-zlib-jll-in-julia-1-6-package-zlib-jll-does-not-have-jllwrappers-in-its-dependencies/68975 "2021-09-30T12:20:25Z")

</div>

I’m using Julia 1.6.3, and I get an error if I try to use Zlib\_jll or any package that has it as a dependency (eg, CodecZlib or CSV). Adding the package has a compile error: (v1.6) pkg\> activate Foo Activating new en…

---

## [Why is the type of factors not being inferred while multiplying an AbstractQ with a vector?](https://discourse.julialang.org/t/why-is-the-type-of-factors-not-being-inferred-while-multiplying-an-abstractq-with-a-vector/68981)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [September 30, 2021, 11:39am UTC](https://discourse.julialang.org/t/why-is-the-type-of-factors-not-being-inferred-while-multiplying-an-abstractq-with-a-vector/68981 "2021-09-30T11:39:00Z")

</div>

julia\> using LinearAlgebra julia\> Q = qr(rand(30,30)); julia\> Q2 = Q.Q; julia\> @code\_warntype Q2 \* rand(size(Q2,2)) MethodInstance for \*(::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}}, ::Vector{Float64}) fro…

---

## [Using current variable values in the naming of DataFrame column(s)](https://discourse.julialang.org/t/using-current-variable-values-in-the-naming-of-dataframe-column-s/68982)

<div class="topic-metadata">

**Author:** [@conorhassan](https://discourse.julialang.org/u/conorhassan)\
**Replies:** 5\
**Last updated:** [September 30, 2021, 11:09am UTC](https://discourse.julialang.org/t/using-current-variable-values-in-the-naming-of-dataframe-column-s/68982 "2021-09-30T11:09:39Z")

</div>

Hi there, The following code chunk is written in R which I would like to replicate in Julia in order to name a variable using the current assigned value for a variable, which is going to change within an iterator: \> mu…

---

## [Julia 1.6 vs 1.5.3 Docker image error](https://discourse.julialang.org/t/julia-1-6-vs-1-5-3-docker-image-error/57995)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 4\
**Last updated:** [September 30, 2021, 3:07am UTC](https://discourse.julialang.org/t/julia-1-6-vs-1-5-3-docker-image-error/57995 "2021-09-30T03:07:27Z")

</div>

I’m trying to create a Docker image for a web app. It works using Julia 1.5.3, but fails with Julia 1.6 with the following(truncated) error: #6 96.06 Building WebIO ───→ \`~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b6…

---

## [Findall return type](https://discourse.julialang.org/t/findall-return-type/68971)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 0\
**Last updated:** [September 29, 2021, 11:12pm UTC](https://discourse.julialang.org/t/findall-return-type/68971 "2021-09-29T23:12:18Z")

</div>

Following from related discussion Keeping Up With The Cartesians - Findall Return Type I understand that findall returns a list of CartesianIndex for a Matrix, which I guess makes sense. But compare this to eachindex w…

---

## [Optional macro invocation](https://discourse.julialang.org/t/optional-macro-invocation/18588)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 21\
**Last updated:** [September 29, 2021, 8:33pm UTC](https://discourse.julialang.org/t/optional-macro-invocation/18588 "2021-09-29T20:33:07Z")

</div>

What’s the idiomatic and DRY way of writing something like this: function foo(async::Bool) if async @async dostuff() else dostuff() end The problem here is that the code is not DRY, I have to call dostuf…

---

## [Navigating Distributions.jl - actual code being run](https://discourse.julialang.org/t/navigating-distributions-jl-actual-code-being-run/68956)

<div class="topic-metadata">

**Author:** [@djholiver](https://discourse.julialang.org/u/djholiver)\
**Replies:** 3\
**Last updated:** [September 29, 2021, 7:08pm UTC](https://discourse.julialang.org/t/navigating-distributions-jl-actual-code-being-run/68956 "2021-09-29T19:08:56Z")

</div>

Hi, I have a need to extend Distributions.pdf(MvNormalCanon(mu, Sigma),DIstributionMatrix :: Matrix{Float}) to replace the DistributionMatrix with an Arrow.Table, however, embarrassingly, I am unable to find the actua…

---

## [Save interactive html plot with Plots.jl](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 8\
**Last updated:** [September 29, 2021, 3:41pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933 "2021-09-29T15:41:37Z")

</div>

I produced a plot with Plots.jl and plotly backend. In jupyter notebook, this plot has basic interactivity like zooming and tooltips. I would like to save it to say HTML so that this basic interactivity is preserved. I t…

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

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