# General Usage

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

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

**Page:** 506

---

## [Confusing ambiguous MethodError](https://discourse.julialang.org/t/confusing-ambiguous-methoderror/73380)

<div class="topic-metadata">

**Author:** [@NicholasWMRitchie](https://discourse.julialang.org/u/NicholasWMRitchie)\
**Replies:** 3\
**Last updated:** [December 20, 2021, 5:00pm UTC](https://discourse.julialang.org/t/confusing-ambiguous-methoderror/73380 "2021-12-20T17:00:10Z")

</div>

While using SQLite.jl, I’ve run into this error (but I don’t think it is really a SQLite question.) MethodError: promote\_type(::Type{Union{}}, ::Type{String}) is ambiguous. Candidates: promote\_type(::Type{Union{}}, ::…

---

## [Avoid double stacktrace when logging error](https://discourse.julialang.org/t/avoid-double-stacktrace-when-logging-error/73374)

<div class="topic-metadata">

**Author:** [@visr](https://discourse.julialang.org/u/visr)\
**Replies:** 1\
**Last updated:** [December 20, 2021, 4:28pm UTC](https://discourse.julialang.org/t/avoid-double-stacktrace-when-logging-error/73374 "2021-12-20T16:28:25Z")

</div>

I have a long running application with custom loggers set up, and when an error is thrown, I want to log that nicely with @error. This is done in a catch block, and works well. Since @error does not throw an error itself…

---

## [Struct with array of pointers to other structs of the same type as field](https://discourse.julialang.org/t/struct-with-array-of-pointers-to-other-structs-of-the-same-type-as-field/73248)

<div class="topic-metadata">

**Author:** [@BelaMulder](https://discourse.julialang.org/u/BelaMulder)\
**Replies:** 3\
**Last updated:** [December 20, 2021, 1:48pm UTC](https://discourse.julialang.org/t/struct-with-array-of-pointers-to-other-structs-of-the-same-type-as-field/73248 "2021-12-20T13:48:29Z")

</div>

Newbie question: I would like to implement lattice structure as an array of structs named Node, where each Node contains as one of its field a list of its neighbouring Nodes in the lattice. My, possibly naive, first try …

---

## [Proper way to install Julia on a multi-user linux VM?](https://discourse.julialang.org/t/proper-way-to-install-julia-on-a-multi-user-linux-vm/73358)

<div class="topic-metadata">

**Author:** [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Replies:** 2\
**Last updated:** [December 20, 2021, 11:27am UTC](https://discourse.julialang.org/t/proper-way-to-install-julia-on-a-multi-user-linux-vm/73358 "2021-12-20T11:27:01Z")

</div>

I can install Julia for a single user easily, but how should I install it on a linux VM so that all users are able to use it properly? My concern is mostly about the loaded packages, pre-compilation, settings, that sort…

---

## [Confused by macros and their hygene](https://discourse.julialang.org/t/confused-by-macros-and-their-hygene/73362)

<div class="topic-metadata">

**Author:** [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Replies:** 3\
**Last updated:** [December 20, 2021, 11:06am UTC](https://discourse.julialang.org/t/confused-by-macros-and-their-hygene/73362 "2021-12-20T11:06:14Z")

</div>

Hello I know there is a simple solution to this but my search skills have failed me. Suppose I have a a macro like macro P(ex) return quote if Print println($ex) end end end then Pr…

---

## [Instantiate ignores the \[compat\] section of a project file](https://discourse.julialang.org/t/instantiate-ignores-the-compat-section-of-a-project-file/73334)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 6\
**Last updated:** [December 20, 2021, 9:29am UTC](https://discourse.julialang.org/t/instantiate-ignores-the-compat-section-of-a-project-file/73334 "2021-12-20T09:29:43Z")

</div>

I have the following Project.toml file (please scroll down to see the end of it): \[deps\] Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" CSV = "336ed68f-0bac-5ca0-8…

---

## [Lazy or efficient representation of \`repeat\` function on Arrays?](https://discourse.julialang.org/t/lazy-or-efficient-representation-of-repeat-function-on-arrays/73356)

<div class="topic-metadata">

**Author:** [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Replies:** 0\
**Last updated:** [December 20, 2021, 4:32am UTC](https://discourse.julialang.org/t/lazy-or-efficient-representation-of-repeat-function-on-arrays/73356 "2021-12-20T04:32:56Z")

</div>

what is the best( lazy ? ) way to represent repeat function (other than doing following) the following julia\> @btime A = repeat(\[1 2\],3,1) 116.760 ns (2 allocations: 192 bytes) 3×2 Matrix{Int64}: 1 2 1 2 1 2 i…

---

## [Problem with parentheses around quoted expression in generated function](https://discourse.julialang.org/t/problem-with-parentheses-around-quoted-expression-in-generated-function/73347)

<div class="topic-metadata">

**Author:** [@evf](https://discourse.julialang.org/u/evf)\
**Replies:** 2\
**Last updated:** [December 19, 2021, 9:36pm UTC](https://discourse.julialang.org/t/problem-with-parentheses-around-quoted-expression-in-generated-function/73347 "2021-12-19T21:36:43Z")

</div>

Hello everyone. I’m trying to use generated functions to write functions that would return the sum of the values of the nearest neighbors of given site in a multidimensional integer periodic lattice. For example: In a …

---

## [Is it possible to apply one schema to different DataFrames?](https://discourse.julialang.org/t/is-it-possible-to-apply-one-schema-to-different-dataframes/73345)

<div class="topic-metadata">

**Author:** [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Replies:** 2\
**Last updated:** [December 19, 2021, 7:59pm UTC](https://discourse.julialang.org/t/is-it-possible-to-apply-one-schema-to-different-dataframes/73345 "2021-12-19T19:59:45Z")

</div>

Hi! I have an external ‘ModelFrame’ that was created like this: sch = schema(model, data, contrasts) f = apply\_schema(model, sch, StatisticalModel) mf = ModelFrame(f, sch, data, StatisticalModel) I kno…

---

## [Nested multi-thread](https://discourse.julialang.org/t/nested-multi-thread/73073)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 13\
**Last updated:** [December 19, 2021, 8:01pm UTC](https://discourse.julialang.org/t/nested-multi-thread/73073 "2021-12-19T20:01:53Z")

</div>

I have N groups. For each group I have J\*K options for each agent i. I want to find the maximum over j,k for each I, and do so for each group n. The problems are all separate from each others. Threads.@threads…

---

## [KernelAbstractions nested task error: UndefVarError: variable not defined](https://discourse.julialang.org/t/kernelabstractions-nested-task-error-undefvarerror-variable-not-defined/73342)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 1\
**Last updated:** [December 19, 2021, 7:03pm UTC](https://discourse.julialang.org/t/kernelabstractions-nested-task-error-undefvarerror-variable-not-defined/73342 "2021-12-19T19:03:14Z")

</div>

Hey, I am facing interesting issues with KernelAbstractions. Why is this code: using KernelAbstractions using CUDA using CUDAKernels @kernel synctesttt(epoch) = begin I = @index(Global) eex=1 while eex \<= epoch @…

---

## [How to simply this without writing a loop?](https://discourse.julialang.org/t/how-to-simply-this-without-writing-a-loop/73337)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 10\
**Last updated:** [December 19, 2021, 6:32pm UTC](https://discourse.julialang.org/t/how-to-simply-this-without-writing-a-loop/73337 "2021-12-19T18:32:06Z")

</div>

For example, I have 4 parameters: A, B, C, and D, each representing an observed property. Each stores a matrix with the size of 360 x 180. Below is my loop: Vars = \["A", "B", "C", "D"\]; for i in Vars if i == "A" …

---

## [MWE fitting a model with a known parameter](https://discourse.julialang.org/t/mwe-fitting-a-model-with-a-known-parameter/73308)

<div class="topic-metadata">

**Author:** [@AlexisRenchon](https://discourse.julialang.org/u/AlexisRenchon)\
**Replies:** 14\
**Last updated:** [December 19, 2021, 5:02pm UTC](https://discourse.julialang.org/t/mwe-fitting-a-model-with-a-known-parameter/73308 "2021-12-19T17:02:18Z")

</div>

Hello, I have a (soil respiration) model, with soil temperature and soil moisture as input variables, and a bunch of parameters, see the code below. I am trying to figure out how to fit the model when one (or more) para…

---

## [Makie 3D scatter animation flow field](https://discourse.julialang.org/t/makie-3d-scatter-animation-flow-field/53056)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 9\
**Last updated:** [December 19, 2021, 4:20pm UTC](https://discourse.julialang.org/t/makie-3d-scatter-animation-flow-field/53056 "2021-12-19T16:20:45Z")

</div>

Hi everyone, I’m trying to make a particle tracking animation of a flow field with Makie. One thing I observed was an “artifact” when the scatter dots move away from the camera. Then they’re surrounded by a small white …

---

## [Transpose vector of vectors](https://discourse.julialang.org/t/transpose-vector-of-vectors/73313)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 11\
**Last updated:** [December 19, 2021, 1:26pm UTC](https://discourse.julialang.org/t/transpose-vector-of-vectors/73313 "2021-12-19T13:26:58Z")

</div>

Is there a shorter way to write this? n = 1000; m = 5000 xss = \[repeat(\[j\], n) for j in 1:m\] yss = \[\[\] for \_ in xss\[1\]\] for xs in xss for (x, ys) in zip(xs, yss) push!(ys, x) end end Maybe there is an…

---

## [Performance benefits of multiple dispatch](https://discourse.julialang.org/t/performance-benefits-of-multiple-dispatch/73254)

<div class="topic-metadata">

**Author:** [@Niall](https://discourse.julialang.org/u/Niall)\
**Replies:** 20\
**Last updated:** [December 19, 2021, 1:03pm UTC](https://discourse.julialang.org/t/performance-benefits-of-multiple-dispatch/73254 "2021-12-19T13:03:14Z")

</div>

OK, so I thought it’d be a great idea to demonstrate to students on their very first lesson the performance benefits of Julia’s Top Notion: multiple dispatch. So I wrote the program shown below. Only problem is, the resu…

---

## [How to get the index of the rows with non-NaN values for multiple vectors?](https://discourse.julialang.org/t/how-to-get-the-index-of-the-rows-with-non-nan-values-for-multiple-vectors/73315)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [December 19, 2021, 3:10am UTC](https://discourse.julialang.org/t/how-to-get-the-index-of-the-rows-with-non-nan-values-for-multiple-vectors/73315 "2021-12-19T03:10:44Z")

</div>

I have 4 vectors of data: A, B, C, D. My goal is to get the index of the rows where all 4 values being non-NaN. Here is my code: Ind1 = intersect.(.!isnan.(A), .!isnan.(B), .!isnan.(C), .!isnan.(D)); Why doesn’t it wo…

---

## [Strange error when performing linear regression](https://discourse.julialang.org/t/strange-error-when-performing-linear-regression/73303)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 3\
**Last updated:** [December 18, 2021, 10:01pm UTC](https://discourse.julialang.org/t/strange-error-when-performing-linear-regression/73303 "2021-12-18T22:01:39Z")

</div>

What is going on here? julia\> x = log.(Nz\_list\[1:end\]) 5-element Vector{Float64}: 4.1588830833596715 4.852030263919617 5.545177444479562 6.238324625039508 6.931471805599453 julia\> julia\> y = log.(dist\_list\[1:end…

---

## [Rethrow error from @async in macro](https://discourse.julialang.org/t/rethrow-error-from-async-in-macro/73244)

<div class="topic-metadata">

**Author:** [@tbenst](https://discourse.julialang.org/u/tbenst)\
**Replies:** 2\
**Last updated:** [December 18, 2021, 10:01pm UTC](https://discourse.julialang.org/t/rethrow-error-from-async-in-macro/73244 "2021-12-18T22:01:34Z")

</div>

I can’t figure out how to properly rethrow an error when using a macro + @async. This is related to Rethrow error from @async and How to get backtrace of \`@async\` Task - #2 by pfitzseb import Base.Threads: @spawn macr…

---

## [Understanding struct hashes](https://discourse.julialang.org/t/understanding-struct-hashes/73202)

<div class="topic-metadata">

**Author:** [@jerlich](https://discourse.julialang.org/u/jerlich)\
**Replies:** 13\
**Last updated:** [December 18, 2021, 6:45pm UTC](https://discourse.julialang.org/t/understanding-struct-hashes/73202 "2021-12-18T18:45:39Z")

</div>

When i change a dictionary the hash changes. julia\> d1 = Dict{Any,Any}() julia\> hash(d1) 0x172af099a2a3a421 julia\> d1\[:A\] = 13245 julia\> hash(d1) 0x9dee08cef4972aa5 If I make a struct with a dictionary the hash of th…

---

## [Another Debugger Problem](https://discourse.julialang.org/t/another-debugger-problem/72870)

<div class="topic-metadata">

**Author:** [@kw\_martin](https://discourse.julialang.org/u/kw_martin)\
**Replies:** 1\
**Last updated:** [December 18, 2021, 6:29pm UTC](https://discourse.julialang.org/t/another-debugger-problem/72870 "2021-12-18T18:29:49Z")

</div>

Still trying to figure out a reasonable debugging strategy. I keep going back and forth between Debugger and VSCode and can’t get either to work adequately. Biggest problem with VSCode is I can’t understand error message…

---

## [I Have a dream! a Green dream -- Does Julia save energy?](https://discourse.julialang.org/t/i-have-a-dream-a-green-dream-does-julia-save-energy/73188)

<div class="topic-metadata">

**Author:** [@SonOfSun](https://discourse.julialang.org/u/SonOfSun)\
**Replies:** 21\
**Last updated:** [December 18, 2021, 4:34pm UTC](https://discourse.julialang.org/t/i-have-a-dream-a-green-dream-does-julia-save-energy/73188 "2021-12-18T16:34:37Z")

</div>

This is not much of a question, more like a possible way to get some more attention to the Julia language. Everybody is talking about we need to save the planet and use less energy. I think it could be a great way to p…

---

## [Package import order change load time](https://discourse.julialang.org/t/package-import-order-change-load-time/73220)

<div class="topic-metadata">

**Author:** [@albheim](https://discourse.julialang.org/u/albheim)\
**Replies:** 2\
**Last updated:** [December 18, 2021, 4:07pm UTC](https://discourse.julialang.org/t/package-import-order-change-load-time/73220 "2021-12-18T16:07:59Z")

</div>

It seems like the order of loading packages can have some impact on the time, mostly got curious about why this happened. Looking at two packages for different load configurations I get albheim@gilbert ~\> hyperfine "ju…

---

## [Julia 1.7 fresh install breaks on updating Pkgs](https://discourse.julialang.org/t/julia-1-7-fresh-install-breaks-on-updating-pkgs/73062)

<div class="topic-metadata">

**Author:** [@AlanAylmer](https://discourse.julialang.org/u/AlanAylmer)\
**Replies:** 9\
**Last updated:** [December 18, 2021, 11:37am UTC](https://discourse.julialang.org/t/julia-1-7-fresh-install-breaks-on-updating-pkgs/73062 "2021-12-18T11:37:35Z")

</div>

Hello Ubuntu 20.04.3 LTS BASH 5.0.17 Julia 1.7 when I update I get a TOML parser error something to with GC and JuMP invalid bare character in my version 1.4 manifest I need Julia to work Should I just revert …

---

## [Profile garbage collection?](https://discourse.julialang.org/t/profile-garbage-collection/73263)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 3\
**Last updated:** [December 18, 2021, 5:36am UTC](https://discourse.julialang.org/t/profile-garbage-collection/73263 "2021-12-18T05:36:24Z")

</div>

Is there a way to profile the garbage collection? For example, to trace which are the variables that are being collected?

---

## [Package Manager resolve complaining of "Unsatisfiable requirements" due to "no known versions"](https://discourse.julialang.org/t/package-manager-resolve-complaining-of-unsatisfiable-requirements-due-to-no-known-versions/23778)

<div class="topic-metadata">

**Author:** [@atteson](https://discourse.julialang.org/u/atteson)\
**Replies:** 6\
**Last updated:** [December 18, 2021, 6:50am UTC](https://discourse.julialang.org/t/package-manager-resolve-complaining-of-unsatisfiable-requirements-due-to-no-known-versions/23778 "2021-12-18T06:50:38Z")

</div>

I frequently get the following error with packages that I’m developing. I usually manage to resolve it but without any understanding or repeatability. How do I tell julia about versions for a package? Am I supposed to…

---

## [Again on reaching optimal parallel scaling](https://discourse.julialang.org/t/again-on-reaching-optimal-parallel-scaling/73203)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 21\
**Last updated:** [December 18, 2021, 2:38am UTC](https://discourse.julialang.org/t/again-on-reaching-optimal-parallel-scaling/73203 "2021-12-18T02:38:34Z")

</div>

This is somewhat vague, and quite certainly not Julia specific, so any bibliography, reference, experience, is appreciated. I am benchmarking an implementation of cell lists to compute particle interactions and other pr…

---

## [Anonymous functions slower than proper functions?](https://discourse.julialang.org/t/anonymous-functions-slower-than-proper-functions/73275)

<div class="topic-metadata">

**Author:** [@FHell](https://discourse.julialang.org/u/FHell)\
**Replies:** 2\
**Last updated:** [December 17, 2021, 7:18pm UTC](https://discourse.julialang.org/t/anonymous-functions-slower-than-proper-functions/73275 "2021-12-17T19:18:29Z")

</div>

Is this expected behavior? I see a performance difference of a factor two for very simple functions. E.g.: using BenchmarkTools g1 = t -\> cos(t - 0.5 \* t^2) g2(t) = cos(t - 0.5 \* t^2) function h1() x = 0. for …

---

## [Inference problem with findall](https://discourse.julialang.org/t/inference-problem-with-findall/73262)

<div class="topic-metadata">

**Author:** [@etienne\_dg](https://discourse.julialang.org/u/etienne_dg)\
**Replies:** 5\
**Last updated:** [December 17, 2021, 2:38pm UTC](https://discourse.julialang.org/t/inference-problem-with-findall/73262 "2021-12-17T14:38:06Z")

</div>

Hi, the following code is not correctly inferred in julia 1.7.0. function test() k = 1 if k == 1 k = 2 end return findall(x -\> x \>= k, \[1\]) end julia\> @code\_warntype(test()) MethodInstance for t…

---

## [Channel take if available](https://discourse.julialang.org/t/channel-take-if-available/73252)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [December 17, 2021, 1:55pm UTC](https://discourse.julialang.org/t/channel-take-if-available/73252 "2021-12-17T13:55:54Z")

</div>

Hi all :slight\_smile: Is there a way to take an element from a Channel if and only if there are elements available. This should be non blocking. I could do something like: julia\> c = Channel(10) Channel{Any}(10) (empt…

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

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