# General Usage

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

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

**Page:** 563

---

## [Segmentation fault after update in Juno](https://discourse.julialang.org/t/segmentation-fault-after-update-in-juno/35072)

<div class="topic-metadata">

**Author:** [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Replies:** 14\
**Last updated:** [August 11, 2021, 3:09pm UTC](https://discourse.julialang.org/t/segmentation-fault-after-update-in-juno/35072 "2021-08-11T15:09:29Z")

</div>

I have upgraded julia-client package in Atom. There was a prompt to upgrade Atom package in Juno (using Pkg.update). And afterwards Atom Repl gives segmentation fault when doing using Plots and pressing any button. The s…

---

## [@generated function - iterate over function argument](https://discourse.julialang.org/t/generated-function-iterate-over-function-argument/66087)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 9\
**Last updated:** [August 11, 2021, 3:06pm UTC](https://discourse.julialang.org/t/generated-function-iterate-over-function-argument/66087 "2021-08-11T15:06:14Z")

</div>

Hi there, I would like to learn a bit more about generated functions. My goal is to convert a struct into a tuple. I already achieved that if I want to convert all fields struct Teststruct{A,B,C} a :: A b :…

---

## [N-dim dict](https://discourse.julialang.org/t/n-dim-dict/66186)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [August 11, 2021, 2:40pm UTC](https://discourse.julialang.org/t/n-dim-dict/66186 "2021-08-11T14:40:56Z")

</div>

Hey all :slight\_smile: I’m looking for something similar like a Array{T,N} but I want to index it with something hashable. I also want to do something like dict\[A("key"), :\] to get everything from the second dimension w…

---

## [REPL with the testing enviroment of a package](https://discourse.julialang.org/t/repl-with-the-testing-enviroment-of-a-package/66200)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 2\
**Last updated:** [August 11, 2021, 1:51pm UTC](https://discourse.julialang.org/t/repl-with-the-testing-enviroment-of-a-package/66200 "2021-08-11T13:51:54Z")

</div>

Is there a way to activate the environment which is used for tests in a REPL (i.e. loading the packages specified in the \[extra\] section of Project.toml)? (or, asked differently: When you work on PRs, in which environme…

---

## [Convert n number of 1\*1 matrices to one n\*1 vector](https://discourse.julialang.org/t/convert-n-number-of-1-1-matrices-to-one-n-1-vector/66182)

<div class="topic-metadata">

**Author:** [@Chaitanya](https://discourse.julialang.org/u/Chaitanya)\
**Replies:** 7\
**Last updated:** [August 11, 2021, 1:30pm UTC](https://discourse.julialang.org/t/convert-n-number-of-1-1-matrices-to-one-n-1-vector/66182 "2021-08-11T13:30:41Z")

</div>

k=collect(0:0.1:1) u is a neural network. pred=(u.(k)) 11-element Vector{Matrix{Float64}}: \[-0.48909483506995793\] \[-0.46596887211781113\] \[-0.44329630895872524\] \[-0.4211157735999599\] \[-0.39946203623807897\] \[-0.378…

---

## [Questions about the use of MLJ](https://discourse.julialang.org/t/questions-about-the-use-of-mlj/66199)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 0\
**Last updated:** [August 11, 2021, 12:54pm UTC](https://discourse.julialang.org/t/questions-about-the-use-of-mlj/66199 "2021-08-11T12:54:02Z")

</div>

I want to use MLJ to realize a multivariate probabilistic prediction algorithm, and the input and output of the model are multi-dimensional matrix. For example, IF I want to combine LSTM and quantile regression algorith…

---

## [What functions might break ForwardDiff.jl?](https://discourse.julialang.org/t/what-functions-might-break-forwarddiff-jl/64694)

<div class="topic-metadata">

**Author:** [@Eemilp](https://discourse.julialang.org/u/Eemilp)\
**Replies:** 10\
**Last updated:** [August 11, 2021, 12:46pm UTC](https://discourse.julialang.org/t/what-functions-might-break-forwarddiff-jl/64694 "2021-08-11T12:46:48Z")

</div>

Hi, are there some julia functions that might cause problems for ForwardDiff.jl? I’m using ForwardDiff.jl to take the derivative of a simulation output. For some reason the output differs slightly in some parts of the cu…

---

## [Dispatch checker](https://discourse.julialang.org/t/dispatch-checker/66191)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 8\
**Last updated:** [August 11, 2021, 11:27am UTC](https://discourse.julialang.org/t/dispatch-checker/66191 "2021-08-11T11:27:58Z")

</div>

Having managed to express your if typeof(v) by suitable dispatch calls, how do you check if they are correct or cover all possible cases? Of course, like in other programming languages, one can always code test cases. …

---

## [How to apply \`Iterators.drop\` on an \`Iterators.Stateful\`?](https://discourse.julialang.org/t/how-to-apply-iterators-drop-on-an-iterators-stateful/27144)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 5\
**Last updated:** [August 11, 2021, 10:20am UTC](https://discourse.julialang.org/t/how-to-apply-iterators-drop-on-an-iterators-stateful/27144 "2021-08-11T10:20:56Z")

</div>

See the following MWE: julia\> a = Iterators.Stateful("123456789"); julia\> b = Iterators.drop(a, 3) Base.Iterators.Drop{Base.Iterators.Stateful{String,Union{Nothing, Tuple{Char,Int64}}}}(Base.Iterators.Stateful{String,U…

---

## [Single index contraction in sparse matrix multiplication of multidimensional array](https://discourse.julialang.org/t/single-index-contraction-in-sparse-matrix-multiplication-of-multidimensional-array/66187)

<div class="topic-metadata">

**Author:** [@SMijin](https://discourse.julialang.org/u/SMijin)\
**Replies:** 0\
**Last updated:** [August 11, 2021, 9:43am UTC](https://discourse.julialang.org/t/single-index-contraction-in-sparse-matrix-multiplication-of-multidimensional-array/66187 "2021-08-11T09:43:56Z")

</div>

I’d like to be able to effectively do something like C\[a,b,c\] = A\[b,d\]\*B\[a,d,c\], where A is a sparse matrix, and C and B are dense (and C and B could be other ranks, including 1). This is indeed just contraction of a sin…

---

## [No method matching terminate!(::DiffEqSensitivity.FakeIntegrator](https://discourse.julialang.org/t/no-method-matching-terminate-diffeqsensitivity-fakeintegrator/66159)

<div class="topic-metadata">

**Author:** [@iqopi](https://discourse.julialang.org/u/iqopi)\
**Replies:** 3\
**Last updated:** [August 11, 2021, 9:16am UTC](https://discourse.julialang.org/t/no-method-matching-terminate-diffeqsensitivity-fakeintegrator/66159 "2021-08-11T09:16:46Z")

</div>

Hey, i am trying to optimize the parameters of a Differential equation using the DiffEqFlux. Since i am only interested into the new steady state, i am using a callback to terminate the integration, once this new state…

---

## [Difference between include, use and import](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 4\
**Last updated:** [August 11, 2021, 9:05am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918 "2021-08-11T09:05:35Z")

</div>

I read about include, use and import in Julia. It seems they can all be used to ‘import’ a module. But I am still not very clear the difference between include, use and import. if I have a module called Mymod, and I w…

---

## [Can I make a named Union of Types](https://discourse.julialang.org/t/can-i-make-a-named-union-of-types/66177)

<div class="topic-metadata">

**Author:** [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)\
**Replies:** 7\
**Last updated:** [August 11, 2021, 6:51am UTC](https://discourse.julialang.org/t/can-i-make-a-named-union-of-types/66177 "2021-08-11T06:51:15Z")

</div>

I am learning how to make one library compatible with another. They both have different type hierarchies for representing a file path. One uses AbstractString, the other uses SystemPath for their abstract representation…

---

## [Loop over SafeTestsets](https://discourse.julialang.org/t/loop-over-safetestsets/66181)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 0\
**Last updated:** [August 11, 2021, 6:34am UTC](https://discourse.julialang.org/t/loop-over-safetestsets/66181 "2021-08-11T06:34:43Z")

</div>

When using SafeTestsets, is any way to do something like the following? for (name, file) in TESTS @safetestset name begin include(file) end end This (and any variation I’ve tried) always gives me ArgumentError: Us…

---

## [Plot the distribution curve](https://discourse.julialang.org/t/plot-the-distribution-curve/66133)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 7\
**Last updated:** [August 11, 2021, 6:16am UTC](https://discourse.julialang.org/t/plot-the-distribution-curve/66133 "2021-08-11T06:16:57Z")

</div>

How to draw a distribution curve？ such as a normal distribution, its format is: Distributions.Normal{Float64}(μ=-0.42117172154916505, σ=1.2253594150160463) thanks！

---

## [A question about drawing](https://discourse.julialang.org/t/a-question-about-drawing/66140)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 3\
**Last updated:** [August 11, 2021, 2:51am UTC](https://discourse.julialang.org/t/a-question-about-drawing/66140 "2021-08-11T02:51:43Z")

</div>

p1 = range(0, 360; length = 100)' # parameter 1 p2 = range(0, 360; length = 70) # parameter 2 w1 = @. sind(3\*(p1 + 2 \* p2)) + 1.25 # wave 1 w2 = @. 6 + w1 \* cosd(p1) # wave 2 x = vec(@. w2 \* cosd(p2)) y = ve…

---

## [How to benchmark properly? Should defaults change?](https://discourse.julialang.org/t/how-to-benchmark-properly-should-defaults-change/66138)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 13\
**Last updated:** [August 10, 2021, 9:48pm UTC](https://discourse.julialang.org/t/how-to-benchmark-properly-should-defaults-change/66138 "2021-08-10T21:48:27Z")

</div>

What is correct here? I guess is the one with evals=1. In that case, couldn’t it be the default option? julia\> using BenchmarkTools julia\> @btime sin(5.0) 1.538 ns (0 allocations: 0 bytes) -0.9589242746631385 julia\> …

---

## [How to determine cpu\_target of a sysimage](https://discourse.julialang.org/t/how-to-determine-cpu-target-of-a-sysimage/66150)

<div class="topic-metadata">

**Author:** [@bluesmoon](https://discourse.julialang.org/u/bluesmoon)\
**Replies:** 0\
**Last updated:** [August 10, 2021, 8:31pm UTC](https://discourse.julialang.org/t/how-to-determine-cpu-target-of-a-sysimage/66150 "2021-08-10T20:31:04Z")

</div>

tl;dr I’m using julia 1.5.4, and I have a few custom sysimages. Is there a way to tell what cpu\_target these sysimages were compiled for? Background I create a docker image with julia, A few of the build stages involve…

---

## [@turbo on sets of operations](https://discourse.julialang.org/t/turbo-on-sets-of-operations/66068)

<div class="topic-metadata">

**Author:** [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)\
**Replies:** 15\
**Last updated:** [August 10, 2021, 3:10pm UTC](https://discourse.julialang.org/t/turbo-on-sets-of-operations/66068 "2021-08-10T15:10:35Z")

</div>

Hello, I’m thinking of adding LoopVectorization.jl to my code to speed it up. All the examples I’ve found are very short on simple operations within a matrix or vector. My code is not as neat, but I often have to perfor…

---

## [Algebra of Graphics z-order? Controlling the plotting order](https://discourse.julialang.org/t/algebra-of-graphics-z-order-controlling-the-plotting-order/66112)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 4\
**Last updated:** [August 10, 2021, 2:48pm UTC](https://discourse.julialang.org/t/algebra-of-graphics-z-order-controlling-the-plotting-order/66112 "2021-08-10T14:48:55Z")

</div>

With Algebra of Graphics + Makie, how do I control the z-order of plots, i.e. which plot goes on top of which? Take this examples for the AoG documentation: http://juliaplots.org/AlgebraOfGraphics.jl/stable/generated/ga…

---

## [On types of functions](https://discourse.julialang.org/t/on-types-of-functions/66058)

<div class="topic-metadata">

**Author:** [@Judd](https://discourse.julialang.org/u/Judd)\
**Replies:** 3\
**Last updated:** [August 10, 2021, 11:58am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058 "2021-08-10T11:58:28Z")

</div>

I propose to add a subsection “Type of Functions” to Manual / Types. This will be very helpful, especially for newcomers to learn the essentials of Julia types and functions. If anything wrong, please correct me. Types…

---

## [Intermediate results (dereferencing, CSE, ..) - when to avoid?](https://discourse.julialang.org/t/intermediate-results-dereferencing-cse-when-to-avoid/66024)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 6\
**Last updated:** [August 10, 2021, 10:05am UTC](https://discourse.julialang.org/t/intermediate-results-dereferencing-cse-when-to-avoid/66024 "2021-08-10T10:05:04Z")

</div>

A habit tells me to eliminate common subexpressions and to create intermediate variables. On the other hand, Julia’s performance is often judged by its allocations and so seems to suggest avoiding intermediate variables…

---

## [Copy an atomic variable as a regular variable](https://discourse.julialang.org/t/copy-an-atomic-variable-as-a-regular-variable/66117)

<div class="topic-metadata">

**Author:** [@matthiasbe](https://discourse.julialang.org/u/matthiasbe)\
**Replies:** 1\
**Last updated:** [August 10, 2021, 9:57am UTC](https://discourse.julialang.org/t/copy-an-atomic-variable-as-a-regular-variable/66117 "2021-08-10T09:57:38Z")

</div>

Hello, I am trying to read the value of an atomic (shared) variable as a local (on the current thread) variable. Here is what I tried. julia\> a = Threads.Atomic{Int}(2) Base.Threads.Atomic{Int64}(2) julia\> b = conver…

---

## [Wrapper{Type{Int}} really needed?](https://discourse.julialang.org/t/wrapper-type-int-really-needed/65877)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 5\
**Last updated:** [August 10, 2021, 8:35am UTC](https://discourse.julialang.org/t/wrapper-type-int-really-needed/65877 "2021-08-10T08:35:09Z")

</div>

Julia’s documentation recommends to wrap types into Type{...} for performance considerations The concrete example in the documentation is julia\> struct WrapType{T} value::T end julia\> WrapType(Float64) #…

---

## [Union causes incorrect type parameter extraction?](https://discourse.julialang.org/t/union-causes-incorrect-type-parameter-extraction/65953)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 15\
**Last updated:** [August 10, 2021, 6:51am UTC](https://discourse.julialang.org/t/union-causes-incorrect-type-parameter-extraction/65953 "2021-08-10T06:51:44Z")

</div>

function fun(x::Union{AbstractArray{T}, AbstractArray{Union{T, Missing}}}; α::T = T(3.0) ) where {T\<:AbstractFloat} println(typeof(x)) end julia\> fun(\[1.0, 2.0\]) Vector{Float64} julia\> fun(\[1.0, missing…

---

## [Julia sure looks like it needs a version of Hoogle](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098)

<div class="topic-metadata">

**Author:** [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)\
**Replies:** 20\
**Last updated:** [August 10, 2021, 12:51am UTC](https://discourse.julialang.org/t/julia-sure-looks-like-it-needs-a-version-of-hoogle/66098 "2021-08-10T00:51:56Z")

</div>

I’m new to Julia. Finding functions seems more difficult than I’d hoped. Smalltalk lets me find references to Classes and implementors of method selector Symbols. I can also inspect instances of a class and browse the n…

---

## [\`addprocs\` crashes with \`connection refused (ECONNREFUSED)\`](https://discourse.julialang.org/t/addprocs-crashes-with-connection-refused-econnrefused/66099)

<div class="topic-metadata">

**Author:** [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Replies:** 0\
**Last updated:** [August 9, 2021, 11:55pm UTC](https://discourse.julialang.org/t/addprocs-crashes-with-connection-refused-econnrefused/66099 "2021-08-09T23:55:23Z")

</div>

I ssh’d into a machine that is (afaik) not virtualized or anything and ran JULIA\_EXCLUSIVE=1 julia-1.6.2/bin/julia --threads 128 langevin/langevin.jl &\> out.txt & and it crashed with the output below. langevin.jl star…

---

## [Can macros know if a variable is local or global?](https://discourse.julialang.org/t/can-macros-know-if-a-variable-is-local-or-global/66093)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [August 9, 2021, 8:58pm UTC](https://discourse.julialang.org/t/can-macros-know-if-a-variable-is-local-or-global/66093 "2021-08-09T20:58:12Z")

</div>

I’m writing a macro that walks the expression tree of a function definition, and would like to know if certain variables are local or global, e.g. if it saw @mymacro function foo() x = 1 return x + y end it nee…

---

## [Is it possible to update the documentation to specify why using parametric methods might be beneficial?](https://discourse.julialang.org/t/is-it-possible-to-update-the-documentation-to-specify-why-using-parametric-methods-might-be-beneficial/66089)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 1\
**Last updated:** [August 9, 2021, 8:31pm UTC](https://discourse.julialang.org/t/is-it-possible-to-update-the-documentation-to-specify-why-using-parametric-methods-might-be-beneficial/66089 "2021-08-09T20:31:01Z")

</div>

Consider the following example from the documentation same\_type(x::T, y::T) where {T} = true same\_type(x,y) = false same\_type(1, 2) # True same\_type(1, 2.0) # False A new comer might wonder why they just can’t write i…

---

## [Plotting for Julia Reinforcement Learning policies](https://discourse.julialang.org/t/plotting-for-julia-reinforcement-learning-policies/66090)

<div class="topic-metadata">

**Author:** [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Replies:** 0\
**Last updated:** [August 9, 2021, 8:30pm UTC](https://discourse.julialang.org/t/plotting-for-julia-reinforcement-learning-policies/66090 "2021-08-09T20:30:16Z")

</div>

I have not done much work with reinforcement learning before, so I was looking over some books on RL algorithms etc., The JuliaReinforcmentLearning organization has put together a really nice package with lots of algorit…

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

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