# General Usage

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

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

**Page:** 518

---

## [Create multiple tasks in a loop](https://discourse.julialang.org/t/create-multiple-tasks-in-a-loop/71701)

<div class="topic-metadata">

**Author:** [@Bossax](https://discourse.julialang.org/u/Bossax)\
**Replies:** 5\
**Last updated:** [November 19, 2021, 7:54pm UTC](https://discourse.julialang.org/t/create-multiple-tasks-in-a-loop/71701 "2021-11-19T19:54:18Z")

</div>

Hi everyone, I am trying to create multiple tasks in a forr loop using @eval. Here is a block of code f(k) = begin sleep(1) println("t$k is done") end begin for k in 1:4 @eval $(Symbol(:t,k)) = @tas…

---

## [Dispatch Problems](https://discourse.julialang.org/t/dispatch-problems/71793)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 2\
**Last updated:** [November 19, 2021, 7:43pm UTC](https://discourse.julialang.org/t/dispatch-problems/71793 "2021-11-19T19:43:05Z")

</div>

I thought I knew how dispatch worked, at least to some degree. It is not working as expected. I am using 1.6.3. First a MWE with 3 methods. function foo(; count::Bool = false) foo(:ANY, count) end function foo(id::…

---

## [Does Julia detect the maximum number of threads availible and if so how?](https://discourse.julialang.org/t/does-julia-detect-the-maximum-number-of-threads-availible-and-if-so-how/71683)

<div class="topic-metadata">

**Author:** [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Replies:** 29\
**Last updated:** [November 19, 2021, 6:27pm UTC](https://discourse.julialang.org/t/does-julia-detect-the-maximum-number-of-threads-availible-and-if-so-how/71683 "2021-11-19T18:27:50Z")

</div>

New to julia and experimenting with threads. I can’t seem to figure out how Julia determines JULIA\_NUM\_THREADS I have two Intel xeon 2699 v3 in my hp z840 Intel blurb on 2699 v3 So what should JULIA\_NUM\_THREADS end…

---

## [Benchmarking MPI programs?](https://discourse.julialang.org/t/benchmarking-mpi-programs/71775)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [November 19, 2021, 6:00pm UTC](https://discourse.julialang.org/t/benchmarking-mpi-programs/71775 "2021-11-19T18:00:00Z")

</div>

Has anyone tried to get BenchmarkTools.jl to play nicely with MPI? I’ve been struggling with intermittent hangs\*. It seems without thinking too hard like it should be possible to make @benchmark MPI-aware pretty easily (…

---

## [Am I misunderstanding the doc for @logmsg?](https://discourse.julialang.org/t/am-i-misunderstanding-the-doc-for-logmsg/71792)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 0\
**Last updated:** [November 19, 2021, 5:49pm UTC](https://discourse.julialang.org/t/am-i-misunderstanding-the-doc-for-logmsg/71792 "2021-11-19T17:49:57Z")

</div>

I’m trying to write a macro to customize the behavior of logging a bit. Logging · The Julia Language says \_file=string and \_line=integer can be used to override the apparent source location of a log message. This te…

---

## [Aliasing with Makie contourf](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783)

<div class="topic-metadata">

**Author:** [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Replies:** 4\
**Last updated:** [November 19, 2021, 3:33pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783 "2021-11-19T15:33:36Z")

</div>

Is there a way to get rid of the aliasing in the contourf! lines in the following example? using CairoMakie function testcontourf() xs = LinRange(0, 10, 100) ys = LinRange(0, 10, 100) zs = \[cos(x) \* sin(y) …

---

## [Running Julia programs as a service/Unix daemon](https://discourse.julialang.org/t/running-julia-programs-as-a-service-unix-daemon/71770)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 0\
**Last updated:** [November 19, 2021, 11:53am UTC](https://discourse.julialang.org/t/running-julia-programs-as-a-service-unix-daemon/71770 "2021-11-19T11:53:36Z")

</div>

Is there some package available similar to: Writing a program to become a well-behaved Unix daemon is somewhat complex and tricky to get right, yet the steps are largely similar for any daemon regardless of what else…

---

## [No method matching loop\_einsum](https://discourse.julialang.org/t/no-method-matching-loop-einsum/71638)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 1\
**Last updated:** [November 19, 2021, 10:58am UTC](https://discourse.julialang.org/t/no-method-matching-loop-einsum/71638 "2021-11-19T10:58:54Z")

</div>

How to deal with this when I used the Optim.jl and Zygote.jl packages for optimization, that the function used OMEinsum.jl. ERROR: LoadError: MethodError: no method matching loop\_einsum(::EinCode{((), (2, 1, 3)),(1, 2…

---

## [Strange behavior of intersect() when applied to ranges](https://discourse.julialang.org/t/strange-behavior-of-intersect-when-applied-to-ranges/22313)

<div class="topic-metadata">

**Author:** [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)\
**Replies:** 10\
**Last updated:** [November 19, 2021, 10:32am UTC](https://discourse.julialang.org/t/strange-behavior-of-intersect-when-applied-to-ranges/22313 "2021-11-19T10:32:50Z")

</div>

When trying to intersect two ranges I stumbled upon the following behavior: julia\> intersect(2:8, 4:10) 4:8 julia\> intersect(2:7, 5:10) 5:7 julia\> intersect(2:6, 6:10) 6:6 julia\> intersect(2:5, 7:10) 7:6 julia\> inte…

---

## [Sorting a vector of fixed size](https://discourse.julialang.org/t/sorting-a-vector-of-fixed-size/71766)

<div class="topic-metadata">

**Author:** [@AdamR](https://discourse.julialang.org/u/AdamR)\
**Replies:** 5\
**Last updated:** [November 19, 2021, 10:25am UTC](https://discourse.julialang.org/t/sorting-a-vector-of-fixed-size/71766 "2021-11-19T10:25:17Z")

</div>

I need to solve a combinatorics problem, that requires, among others, finding and sortperm (a.k.a. argsort) for thousands of millions of vectors of fixed size. It so happens that the size of the vector is known at the c…

---

## [Possible bug with tuple values in type arguments](https://discourse.julialang.org/t/possible-bug-with-tuple-values-in-type-arguments/71750)

<div class="topic-metadata">

**Author:** [@bgroenks](https://discourse.julialang.org/u/bgroenks)\
**Replies:** 2\
**Last updated:** [November 19, 2021, 9:39am UTC](https://discourse.julialang.org/t/possible-bug-with-tuple-values-in-type-arguments/71750 "2021-11-19T09:39:46Z")

</div>

Hi all, Can anyone explain why the following works: Val{(:a,:b,:c)}() but this does not? Val{(:a,:b,(:c,:d))}() ERROR: TypeError: in Type, in parameter, expected Type, got a value of type Tuple{Symbol, Symbol, Tuple…

---

## [Derivative using Interpolations.jl failing](https://discourse.julialang.org/t/derivative-using-interpolations-jl-failing/71759)

<div class="topic-metadata">

**Author:** [@vtomar](https://discourse.julialang.org/u/vtomar)\
**Replies:** 1\
**Last updated:** [November 19, 2021, 6:29am UTC](https://discourse.julialang.org/t/derivative-using-interpolations-jl-failing/71759 "2021-11-19T06:29:01Z")

</div>

I was trying to compute gradient of the points in the y-variable but it errors out: using Interpolations x = 1:6; y = \[1.0,2.0,3.0, 5.0, 10.0, 7.0\]; itp = interpolate((x,), y, Gridded(Linear())); only.(Interpolations.g…

---

## [Why is :1 === 1?](https://discourse.julialang.org/t/why-is-1-1/71752)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 2\
**Last updated:** [November 19, 2021, 12:36am UTC](https://discourse.julialang.org/t/why-is-1-1/71752 "2021-11-19T00:36:26Z")

</div>

julia\> :1 === 1 true I don’t know what else it would be, but why that?

---

## [Micro benchmarks of kron for vectors](https://discourse.julialang.org/t/micro-benchmarks-of-kron-for-vectors/71689)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 6\
**Last updated:** [November 18, 2021, 12:05pm UTC](https://discourse.julialang.org/t/micro-benchmarks-of-kron-for-vectors/71689 "2021-11-18T12:05:03Z")

</div>

Edit: corrected according to @jling \`s comment Inspired by another thread here is a micro benchmark of Base.kron for Vector using LinearAlgebra using BenchmarkTools function \_kron(A::Matrix, B::Matrix) C = zeros(s…

---

## [Long latex expressions in Pluto](https://discourse.julialang.org/t/long-latex-expressions-in-pluto/71718)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 0\
**Last updated:** [November 18, 2021, 11:38am UTC](https://discourse.julialang.org/t/long-latex-expressions-in-pluto/71718 "2021-11-18T11:38:04Z")

</div>

Sometimes, using for example MultivariatePolynomials.jl, Pluto tries to render very large \\LaTeX expressions and (almost) freezes for a while. Of course this happens only when I forget to suppress the output which I don’…

---

## [Recommended way to use something like \`evalpoly\` with \`@turbo\` from LoopVectorization.jl](https://discourse.julialang.org/t/recommended-way-to-use-something-like-evalpoly-with-turbo-from-loopvectorization-jl/71706)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 2\
**Last updated:** [November 18, 2021, 11:31am UTC](https://discourse.julialang.org/t/recommended-way-to-use-something-like-evalpoly-with-turbo-from-loopvectorization-jl/71706 "2021-11-18T11:31:00Z")

</div>

What is the recommended way to evaluate polynomials inside loops annotated by @turbo from LoopVectorization.jl? Apparently, neither @evalpoly nor evalpoly work directly. julia\> using LoopVectorization julia\> function f…

---

## [Allocation during access to "typed" field of mutable struct](https://discourse.julialang.org/t/allocation-during-access-to-typed-field-of-mutable-struct/56201)

<div class="topic-metadata">

**Author:** [@Dilchatto](https://discourse.julialang.org/u/Dilchatto)\
**Replies:** 11\
**Last updated:** [November 18, 2021, 11:16am UTC](https://discourse.julialang.org/t/allocation-during-access-to-typed-field-of-mutable-struct/56201 "2021-11-18T11:16:01Z")

</div>

I have following struct mutable struct Element{T\<:AbstractElement} \<: AbstractElement input::StringBuffer name::UnitRange{Int64} attributes::Union{Nothing, Attribute} value::Union{T, Nothing} parent:…

---

## [How to "localize" slicing an array?](https://discourse.julialang.org/t/how-to-localize-slicing-an-array/71691)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 3\
**Last updated:** [November 18, 2021, 9:15am UTC](https://discourse.julialang.org/t/how-to-localize-slicing-an-array/71691 "2021-11-18T09:15:01Z")

</div>

How can I “localize” slicing on dimension relative to “available” indices? In the example below, I would need L\[:, j\] to mean “get all elements along dimension 1 relative to elements present in skipzeros”. How can I do t…

---

## [Apple silicon full power](https://discourse.julialang.org/t/apple-silicon-full-power/70662)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 19\
**Last updated:** [November 18, 2021, 9:13am UTC](https://discourse.julialang.org/t/apple-silicon-full-power/70662 "2021-11-18T09:13:59Z")

</div>

First of all, I would like to thank for the efforts put in v1.7 that supports Apple silicon CPU :100: :bowing\_man: Just two years or so earlier, no body understands why Apple going away from standard GPU libraries like …

---

## [Y.A.t.Q : Yet Another @threads Question](https://discourse.julialang.org/t/y-a-t-q-yet-another-threads-question/71541)

<div class="topic-metadata">

**Author:** [@kadir-gunel](https://discourse.julialang.org/u/kadir-gunel)\
**Replies:** 17\
**Last updated:** [November 18, 2021, 7:05am UTC](https://discourse.julialang.org/t/y-a-t-q-yet-another-threads-question/71541 "2021-11-18T07:05:21Z")

</div>

Hello, I am calculating the cosine distance between two vector spaces by using Distances.jl package. Since the vector spaces in comparison are large, I wanted to calculate cosine distances by using @threads. The proble…

---

## [Paradox of normalizing the biggest eigenvalue module to one](https://discourse.julialang.org/t/paradox-of-normalizing-the-biggest-eigenvalue-module-to-one/71664)

<div class="topic-metadata">

**Author:** [@ZhiyuanYao](https://discourse.julialang.org/u/ZhiyuanYao)\
**Replies:** 5\
**Last updated:** [November 18, 2021, 7:01am UTC](https://discourse.julialang.org/t/paradox-of-normalizing-the-biggest-eigenvalue-module-to-one/71664 "2021-11-18T07:01:00Z")

</div>

I run into an interesting but nasty problem in normalizing a matrix so that the largest eigenvalue module is one. The λ in convertMPS\_PBC2OBC should print one, but I got values slightly different from one. The minimum c…

---

## [Multi Dimensional Cubic Spline](https://discourse.julialang.org/t/multi-dimensional-cubic-spline/71687)

<div class="topic-metadata">

**Author:** [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Replies:** 3\
**Last updated:** [November 18, 2021, 5:20am UTC](https://discourse.julialang.org/t/multi-dimensional-cubic-spline/71687 "2021-11-18T05:20:30Z")

</div>

Hi, I’ve a multi dimensional dataset (3 features and 1 label) and want to interpolate using cubic splines. I have found several documentations on interpolation in 2D but can’t find anything that’ll help with this. Lookin…

---

## [Case Study: Percolation](https://discourse.julialang.org/t/case-study-percolation/71694)

<div class="topic-metadata">

**Author:** [@Oko](https://discourse.julialang.org/u/Oko)\
**Replies:** 1\
**Last updated:** [November 18, 2021, 3:32am UTC](https://discourse.julialang.org/t/case-study-percolation/71694 "2021-11-18T03:32:28Z")

</div>

I was wondering if somebody could give me a quick summary of the current Julia ecosystem when it comes to percolation theory? I more or less tried to re-implement this Princeton University programming project but I woul…

---

## [Test on each value of a vector](https://discourse.julialang.org/t/test-on-each-value-of-a-vector/71622)

<div class="topic-metadata">

**Author:** [@corny85](https://discourse.julialang.org/u/corny85)\
**Replies:** 5\
**Last updated:** [November 17, 2021, 7:09pm UTC](https://discourse.julialang.org/t/test-on-each-value-of-a-vector/71622 "2021-11-17T19:09:17Z")

</div>

Hello, I have a vector D and i want to test if all values are less than 1 or not. I’ve tried if(D\[k\]\<1 for k=1:size(D,1)) return true else return false end but it does not work. Thanks in advance for your he…

---

## [DataFrames, get a subset in which the value of a particular column is not missing](https://discourse.julialang.org/t/dataframes-get-a-subset-in-which-the-value-of-a-particular-column-is-not-missing/71680)

<div class="topic-metadata">

**Author:** [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Replies:** 3\
**Last updated:** [November 17, 2021, 8:37pm UTC](https://discourse.julialang.org/t/dataframes-get-a-subset-in-which-the-value-of-a-particular-column-is-not-missing/71680 "2021-11-17T20:37:40Z")

</div>

I’m probably doing something dumb here, but I have a DataFrame and I want to get all rows for which a particular column (which is called :Level and is type Union{Int, Missing}) is not missing. My first two tries (using D…

---

## [Function speed up, reduce allocations](https://discourse.julialang.org/t/function-speed-up-reduce-allocations/71647)

<div class="topic-metadata">

**Author:** [@david.brust](https://discourse.julialang.org/u/david.brust)\
**Replies:** 12\
**Last updated:** [November 17, 2021, 8:27pm UTC](https://discourse.julialang.org/t/function-speed-up-reduce-allocations/71647 "2021-11-17T20:27:53Z")

</div>

Hi, I am working on a combinatorial problem called Block Design: Block design - Wikipedia ( specifically Pairwise balanced uniform designs (2-designs or BIBDs) ) I try to group N=25 samples (e.g. integers 1:25) into “…

---

## [Setfield.jl for parametric type](https://discourse.julialang.org/t/setfield-jl-for-parametric-type/71670)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 0\
**Last updated:** [November 17, 2021, 4:05pm UTC](https://discourse.julialang.org/t/setfield-jl-for-parametric-type/71670 "2021-11-17T16:05:55Z")

</div>

struct B{T, X, Y} x::X y::Y end B{T}(x::X, y::Y = 2) where {T, X, Y} = B{T, X, Y}(x, y) b = B{Int}(2,3) Setfield.@set b.x = 512 # fails

---

## [Dash.jl and interactive REPL?](https://discourse.julialang.org/t/dash-jl-and-interactive-repl/66197)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 7\
**Last updated:** [November 17, 2021, 6:32pm UTC](https://discourse.julialang.org/t/dash-jl-and-interactive-repl/66197 "2021-11-17T18:32:27Z")

</div>

Is there a way to have a Dash.jl application running while at the same time being able to use the REPL interactively?

---

## [Can't convert numerical values to string in a DataFrame (Cannot convert String to Int64)](https://discourse.julialang.org/t/cant-convert-numerical-values-to-string-in-a-dataframe-cannot-convert-string-to-int64/71644)

<div class="topic-metadata">

**Author:** [@wizofe](https://discourse.julialang.org/u/wizofe)\
**Replies:** 5\
**Last updated:** [November 17, 2021, 4:22pm UTC](https://discourse.julialang.org/t/cant-convert-numerical-values-to-string-in-a-dataframe-cannot-convert-string-to-int64/71644 "2021-11-17T16:22:10Z")

</div>

Hi everyone, I want to replace all the numerical (Int) values of a column in a dataframe with a string (“ASD”). I am though getting an error that this isn’t possible. I also tried to use “1”, in which case it doesn’t re…

---

## [Sorting multidimensional arrays](https://discourse.julialang.org/t/sorting-multidimensional-arrays/71657)

<div class="topic-metadata">

**Author:** [@rolim.gustavo](https://discourse.julialang.org/u/rolim.gustavo)\
**Replies:** 3\
**Last updated:** [November 17, 2021, 3:45pm UTC](https://discourse.julialang.org/t/sorting-multidimensional-arrays/71657 "2021-11-17T15:45:48Z")

</div>

Hi, I am currently working on a scheduling problem which has a solution represented by a multidimensional array called Sol. For instance, Sol = \[\[4, 1, 5, 2\], \[3, 6, 10, 9, 7, 8\]\]. Each row is represented by a permutat…

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

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