# General Usage

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

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

**Page:** 618

---

## [Is this impossible for Zygote Adjoint to handle](https://discourse.julialang.org/t/is-this-impossible-for-zygote-adjoint-to-handle/57878)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 4\
**Last updated:** [April 7, 2021, 9:16am UTC](https://discourse.julialang.org/t/is-this-impossible-for-zygote-adjoint-to-handle/57878 "2021-04-07T09:16:00Z")

</div>

The example below I got out of the documentation somewhere. It appears to compute the gradient when done with the QuadratureAdjoint() I don’t get an error. When I switch to the ZygoteAdjoint() I get the error: ERROR: …

---

## [Getting the name of a Struct / Scoping Issues with Custom Structs](https://discourse.julialang.org/t/getting-the-name-of-a-struct-scoping-issues-with-custom-structs/58706)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 8:56pm UTC](https://discourse.julialang.org/t/getting-the-name-of-a-struct-scoping-issues-with-custom-structs/58706 "2021-04-06T20:56:55Z")

</div>

Hi there, I have a scoping issues, and did not manage to find a solution on my own. I was hoping that someone more knowledgeable might have a quick solution for this: I define an abstract type AbstractModel in a modul…

---

## [How to change the default JULIA\_NUM\_THREADS variable? How to call a multi thread julia from a python script?](https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727)

<div class="topic-metadata">

**Author:** [@Noodle](https://discourse.julialang.org/u/Noodle)\
**Replies:** 1\
**Last updated:** [April 7, 2021, 7:23am UTC](https://discourse.julialang.org/t/how-to-change-the-default-julia-num-threads-variable-how-to-call-a-multi-thread-julia-from-a-python-script/58727 "2021-04-07T07:23:22Z")

</div>

Hello everyone, Is there a way to change the DEFAULT number of threads (default is 1) so that every time I use julia.exe it always starts with 4 threads? I know we could manually set it by set JULIA\_NUM\_THREADS = 4 an…

---

## [KeyError when indexing from an OrderedDict in for loop](https://discourse.julialang.org/t/keyerror-when-indexing-from-an-ordereddict-in-for-loop/58731)

<div class="topic-metadata">

**Author:** [@GraceMabele](https://discourse.julialang.org/u/GraceMabele)\
**Replies:** 3\
**Last updated:** [April 7, 2021, 6:15am UTC](https://discourse.julialang.org/t/keyerror-when-indexing-from-an-ordereddict-in-for-loop/58731 "2021-04-07T06:15:53Z")

</div>

How can I access or index an OrderedDict? I tried as below but returning keyerror using DataStructures price = OrderedDict( "s1" =\> 0, "s2" =\> 0, "s3" =\> 0, "s4" =\> 5 ) for s in 1:length(S) price\[s\] end Returns …

---

## [Optimizing remainder with constant modulus implementation](https://discourse.julialang.org/t/optimizing-remainder-with-constant-modulus-implementation/58586)

<div class="topic-metadata">

**Author:** [@pjentsch0](https://discourse.julialang.org/u/pjentsch0)\
**Replies:** 2\
**Last updated:** [April 6, 2021, 2:10pm UTC](https://discourse.julialang.org/t/optimizing-remainder-with-constant-modulus-implementation/58586 "2021-04-06T14:10:53Z")

</div>

Hi performance people! I am implementing the remainder routines for constant modulus from this paper by Lemire et al. in Julia from their C examples. Below is the original C implementation followed by my julia translati…

---

## [Vega and the Iris Dataset](https://discourse.julialang.org/t/vega-and-the-iris-dataset/58470)

<div class="topic-metadata">

**Author:** [@kumarbalachandran](https://discourse.julialang.org/u/kumarbalachandran)\
**Replies:** 11\
**Last updated:** [April 6, 2021, 10:46pm UTC](https://discourse.julialang.org/t/vega-and-the-iris-dataset/58470 "2021-04-06T22:46:38Z")

</div>

I am trying to execute the following script on Julia 1.6.0 #select packages using VegaDatasets using DataVoyager using VegaLite # load dataset data = dataset("iris") #display data vscodedisplay(data) v=Voyager() and I…

---

## [Softmax and large numbers](https://discourse.julialang.org/t/softmax-and-large-numbers/58674)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 7\
**Last updated:** [April 6, 2021, 9:32pm UTC](https://discourse.julialang.org/t/softmax-and-large-numbers/58674 "2021-04-06T21:32:41Z")

</div>

I need to apply a softmax layer to values that are potentially large and I am getting NaN values. Playing around a bit more I found the following: julia\> using CUDA, Flux julia\> softmax(gpu(Float32\[1, 2, 3, Inf\])) 4-el…

---

## [Insert!, cross-module struct mutation and symbol reference](https://discourse.julialang.org/t/insert-cross-module-struct-mutation-and-symbol-reference/58707)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 9:21pm UTC](https://discourse.julialang.org/t/insert-cross-module-struct-mutation-and-symbol-reference/58707 "2021-04-06T21:21:09Z")

</div>

Barkground: The lecture notes for an open courseware class I’m working through uses an interactive Pluto notebook. I wanted to add an empty cell to my local copy of this notebook to work on one of the programming exrci…

---

## [Faster way to "save" and "load" structs](https://discourse.julialang.org/t/faster-way-to-save-and-load-structs/58704)

<div class="topic-metadata">

**Author:** [@RXGottlieb](https://discourse.julialang.org/u/RXGottlieb)\
**Replies:** 4\
**Last updated:** [April 6, 2021, 6:43pm UTC](https://discourse.julialang.org/t/faster-way-to-save-and-load-structs/58704 "2021-04-06T18:43:46Z")

</div>

I’m working on a project in which I need to repeatedly remember the status of my process, make a small change, and then re-load the original status from before the change was made. Think something like a Monte Carlo tree…

---

## [Computing L1 norm between vectors: julian way](https://discourse.julialang.org/t/computing-l1-norm-between-vectors-julian-way/58680)

<div class="topic-metadata">

**Author:** [@ismedina](https://discourse.julialang.org/u/ismedina)\
**Replies:** 14\
**Last updated:** [April 6, 2021, 6:34pm UTC](https://discourse.julialang.org/t/computing-l1-norm-between-vectors-julian-way/58680 "2021-04-06T18:34:43Z")

</div>

I need to code a function that computes the L1 distance between the two vectors. It doesn’t need to be super precise — it serves as the estimate for some error as part of the stopping criterion of an algorithm—, but it n…

---

## [LocalCoverage.jl -\> Function and Branch Coverage](https://discourse.julialang.org/t/localcoverage-jl-function-and-branch-coverage/58012)

<div class="topic-metadata">

**Author:** [@Michal](https://discourse.julialang.org/u/Michal)\
**Replies:** 4\
**Last updated:** [April 6, 2021, 4:44pm UTC](https://discourse.julialang.org/t/localcoverage-jl-function-and-branch-coverage/58012 "2021-04-06T16:44:51Z")

</div>

How to generate Function and Branch coverage? It is generating line coverage by default.

---

## [Threads maxing out all cores, but no performance increase](https://discourse.julialang.org/t/threads-maxing-out-all-cores-but-no-performance-increase/58590)

<div class="topic-metadata">

**Author:** [@seulberg1](https://discourse.julialang.org/u/seulberg1)\
**Replies:** 16\
**Last updated:** [April 6, 2021, 3:06pm UTC](https://discourse.julialang.org/t/threads-maxing-out-all-cores-but-no-performance-increase/58590 "2021-04-06T15:06:41Z")

</div>

Hello All I started using Julia, because of its speed in an application, where the workload in pseudo-code looks like I added below (no MWE, but hopefully this is diagnostic enough - otherwise I will create a MWE, but i…

---

## [Julia 1.6 returns Matrix in case of zeros(m,n), ones(m,n)](https://discourse.julialang.org/t/julia-1-6-returns-matrix-in-case-of-zeros-m-n-ones-m-n/58686)

<div class="topic-metadata">

**Author:** [@praveenc](https://discourse.julialang.org/u/praveenc)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 3:01pm UTC](https://discourse.julialang.org/t/julia-1-6-returns-matrix-in-case-of-zeros-m-n-ones-m-n/58686 "2021-04-06T15:01:43Z")

</div>

Before it used to return an Array. I wonder what is the reason for this change ? Do we have to do something in our existing codes to account for this change ?

---

## [How to read lines from a file with a reusable buffer?](https://discourse.julialang.org/t/how-to-read-lines-from-a-file-with-a-reusable-buffer/58620)

<div class="topic-metadata">

**Author:** [@sstadick](https://discourse.julialang.org/u/sstadick)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 2:19pm UTC](https://discourse.julialang.org/t/how-to-read-lines-from-a-file-with-a-reusable-buffer/58620 "2021-04-06T14:19:20Z")

</div>

What I want to do: line\_buffer = UInt8\[\] buffered\_io\_stream = open("file.txt") while readuntil!(line\_buffer, buffered\_io\_stream, '\\n') != 0 # do thing with line\_buffer # clear line\_buffer end Is there a pack…

---

## [The most general way to estimate the optimal arguments for @cuda macro](https://discourse.julialang.org/t/the-most-general-way-to-estimate-the-optimal-arguments-for-cuda-macro/39342)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 6\
**Last updated:** [April 6, 2021, 2:12pm UTC](https://discourse.julialang.org/t/the-most-general-way-to-estimate-the-optimal-arguments-for-cuda-macro/39342 "2021-04-06T14:12:17Z")

</div>

How one can choose the optimal arguments (threads, blocks, etc.) to launch CUDA kernels using @cuda macro? In the following example I consider a simple kernel which does vector addition of two matrices: using CuArrays u…

---

## [Fast computation of Grammian of matrix](https://discourse.julialang.org/t/fast-computation-of-grammian-of-matrix/56244)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 11\
**Last updated:** [April 6, 2021, 1:16pm UTC](https://discourse.julialang.org/t/fast-computation-of-grammian-of-matrix/56244 "2021-04-06T13:16:09Z")

</div>

For some model indentification problems, I have to compute the grammian of data matrices i.e. compute A = X'\*X where X is a complex rectangular matrix. Is there a fast implementation of this specific operation in julia …

---

## [Accelerate Non-linear function evaluation](https://discourse.julialang.org/t/accelerate-non-linear-function-evaluation/42105)

<div class="topic-metadata">

**Author:** [@bdc](https://discourse.julialang.org/u/bdc)\
**Replies:** 17\
**Last updated:** [April 6, 2021, 12:48pm UTC](https://discourse.julialang.org/t/accelerate-non-linear-function-evaluation/42105 "2021-04-06T12:48:33Z")

</div>

Hi, I’m working on an application with maximum entropy networks. To determine some parameters, a system of non-linear equation F(x)=0 needs to be solved. For a network of n nodes, each node i has an associated equation…

---

## [Multiple inheritance carry-over members](https://discourse.julialang.org/t/multiple-inheritance-carry-over-members/58355)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 13\
**Last updated:** [April 6, 2021, 7:21am UTC](https://discourse.julialang.org/t/multiple-inheritance-carry-over-members/58355 "2021-04-06T07:21:31Z")

</div>

Inheritance vs. mulitple dispatch in julia is maybe one of the hard things to grasp. I am still struggling with it and therefore the question. Does julia have a concept of carrying over data members to derived classes? I…

---

## [First element of iteration satisfying a predicate](https://discourse.julialang.org/t/first-element-of-iteration-satisfying-a-predicate/58617)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [April 6, 2021, 12:08pm UTC](https://discourse.julialang.org/t/first-element-of-iteration-satisfying-a-predicate/58617 "2021-04-06T12:08:39Z")

</div>

I often find that I want to use something like findfirst on iterables that have no (or inefficient) random access, something like function satisfies\_first(predicate, itr) for i in itr predicate(i) && return …

---

## [Stale compile cache moving to Julia 1.6.0?](https://discourse.julialang.org/t/stale-compile-cache-moving-to-julia-1-6-0/58678)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 2\
**Last updated:** [April 6, 2021, 12:09pm UTC](https://discourse.julialang.org/t/stale-compile-cache-moving-to-julia-1-6-0/58678 "2021-04-06T12:09:23Z")

</div>

Hi, I am moving my code to Julia 1.6.0 (from 1.4.x), and in doing so am encountering a problem for which I am not able to create an MWE: I have a module SaidModule, which exports some short names like export R11 const…

---

## [BLAS thread count vs Julia thread count](https://discourse.julialang.org/t/blas-thread-count-vs-julia-thread-count/57197)

<div class="topic-metadata">

**Author:** [@Manuel\_Bergmann](https://discourse.julialang.org/u/Manuel_Bergmann)\
**Replies:** 21\
**Last updated:** [April 6, 2021, 11:02am UTC](https://discourse.julialang.org/t/blas-thread-count-vs-julia-thread-count/57197 "2021-04-06T11:02:11Z")

</div>

Hey, just found that thread now. Is there a reason why BLAS.set\_num\_threads(n) defaults to 8 threads and also ignores Julia’s --threads option? I found that issue while investigating that matrix multiplication benchmark:…

---

## [Can multiple tasks on different threads write from the same Channel without a lock?](https://discourse.julialang.org/t/can-multiple-tasks-on-different-threads-write-from-the-same-channel-without-a-lock/58661)

<div class="topic-metadata">

**Author:** [@smabie](https://discourse.julialang.org/u/smabie)\
**Replies:** 2\
**Last updated:** [April 6, 2021, 6:33am UTC](https://discourse.julialang.org/t/can-multiple-tasks-on-different-threads-write-from-the-same-channel-without-a-lock/58661 "2021-04-06T06:33:08Z")

</div>

Pretty much the title says it all: I want to have multiple producers that all write to the same channel. I will then have one consumer that reads the data from this channel. Do the producers need to acquire a lock before…

---

## [Economy-sized QR decomposition](https://discourse.julialang.org/t/economy-sized-qr-decomposition/57608)

<div class="topic-metadata">

**Author:** [@qrebjock](https://discourse.julialang.org/u/qrebjock)\
**Replies:** 10\
**Last updated:** [April 6, 2021, 6:34am UTC](https://discourse.julialang.org/t/economy-sized-qr-decomposition/57608 "2021-04-06T06:34:59Z")

</div>

Hello, It seems like the function qr doesn’t take keywords argument to return an economy-sized factorization. In this thread qr(A; full=false) no longer available? · Issue #27397 · JuliaLang/julia · GitHub they say tha…

---

## [Economist's doing dynamic programming and structural estimation](https://discourse.julialang.org/t/economists-doing-dynamic-programming-and-structural-estimation/58171)

<div class="topic-metadata">

**Author:** [@jovansam](https://discourse.julialang.org/u/jovansam)\
**Replies:** 12\
**Last updated:** [April 6, 2021, 1:42am UTC](https://discourse.julialang.org/t/economists-doing-dynamic-programming-and-structural-estimation/58171 "2021-04-06T01:42:33Z")

</div>

I love discourse because you get to learn from experts across fields. This is really nice!. At the same time, I would like to learn from people with closely aligned work as mine. Thus, I was wondering whether some econo…

---

## [Fast 4D argmax](https://discourse.julialang.org/t/fast-4d-argmax/58566)

<div class="topic-metadata">

**Author:** [@jroon](https://discourse.julialang.org/u/jroon)\
**Replies:** 26\
**Last updated:** [April 6, 2021, 1:06am UTC](https://discourse.julialang.org/t/fast-4d-argmax/58566 "2021-04-06T01:06:04Z")

</div>

Hi Julia-folks! I’m new to Julia (very new), but work mainly in R. I’m trying to replace a slow bit of R code with a Julia function that I will call from within R. Essentially what I’m trying to achieve is argmax of a 4…

---

## [Julia slows down after computer upgrade](https://discourse.julialang.org/t/julia-slows-down-after-computer-upgrade/58503)

<div class="topic-metadata">

**Author:** [@mengxiaoliu](https://discourse.julialang.org/u/mengxiaoliu)\
**Replies:** 15\
**Last updated:** [April 6, 2021, 12:46am UTC](https://discourse.julialang.org/t/julia-slows-down-after-computer-upgrade/58503 "2021-04-06T00:46:19Z")

</div>

Hi. I am very new to Julia and am not a computer geek so this question may not be very clear. I am happy to add any information as necessary. I am running Julia on VSCode in Windows. I recently added some memory sticks …

---

## [Creating Animation from multiple Images](https://discourse.julialang.org/t/creating-animation-from-multiple-images/58559)

<div class="topic-metadata">

**Author:** [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Replies:** 9\
**Last updated:** [April 5, 2021, 9:15pm UTC](https://discourse.julialang.org/t/creating-animation-from-multiple-images/58559 "2021-04-05T21:15:12Z")

</div>

Hi, I’m working on a project where I’ve to work with reflecting rays. I’ve written the code to trace the rays and reflection, but want to visualize the ray paths (just to quickly make sure that everything works well). I …

---

## [How to avoid boxed function names in closures?](https://discourse.julialang.org/t/how-to-avoid-boxed-function-names-in-closures/58579)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 6\
**Last updated:** [April 5, 2021, 8:29pm UTC](https://discourse.julialang.org/t/how-to-avoid-boxed-function-names-in-closures/58579 "2021-04-05T20:29:18Z")

</div>

Hello! In order to avoid performance problems, I would like to know whether boxes can be avoided in two kinds of closures. Without closures, all problems mentioned below disappear. I’m using Julia 1.6.0. Keyword argumen…

---

## [Interpolation problems](https://discourse.julialang.org/t/interpolation-problems/58631)

<div class="topic-metadata">

**Author:** [@leopdsf](https://discourse.julialang.org/u/leopdsf)\
**Replies:** 2\
**Last updated:** [April 5, 2021, 8:36pm UTC](https://discourse.julialang.org/t/interpolation-problems/58631 "2021-04-05T20:36:41Z")

</div>

Hello there! I have a matrix S(N,2) with data and I want to interpolate S\[:,2\] as a function of S\[:,1\]. I wrote the following using DataInterpolations vm = S\[:,2\] vh = S\[:,1\] im = LinearInterpolation(vm,vh) It pres…

---

## [CAS benchmarks (Symbolics.jl and Maxima)](https://discourse.julialang.org/t/cas-benchmarks-symbolics-jl-and-maxima/58359)

<div class="topic-metadata">

**Author:** [@rfateman](https://discourse.julialang.org/u/rfateman)\
**Replies:** 36\
**Last updated:** [April 5, 2021, 8:06pm UTC](https://discourse.julialang.org/t/cas-benchmarks-symbolics-jl-and-maxima/58359 "2021-04-05T20:06:29Z")

</div>

I still don’t understand why you are touting the speed of Julia symbolic code (compiled) compared to the speed of SymPy (interpreted). I looked for a benchmark that could be run in (say) Maxima, but finally came up a r…

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

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