# General Usage

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

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

**Page:** 468

---

## [Drop specific elements of sparse arrays](https://discourse.julialang.org/t/drop-specific-elements-of-sparse-arrays/78583)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 0\
**Last updated:** [March 28, 2022, 3:58am UTC](https://discourse.julialang.org/t/drop-specific-elements-of-sparse-arrays/78583 "2022-03-28T03:58:59Z")

</div>

Hi, I was wondering if it is possible to drop the i-th element of a sparse vector x (i.e., setting it to zero) in-place. I am aware that you can do something like x\[i\]=0.0; dropzeros!(x), but I was wondering if there is…

---

## [Type instability of nested recursive function](https://discourse.julialang.org/t/type-instability-of-nested-recursive-function/78392)

<div class="topic-metadata">

**Author:** [@ma-chengyuan](https://discourse.julialang.org/u/ma-chengyuan)\
**Replies:** 4\
**Last updated:** [March 28, 2022, 3:38am UTC](https://discourse.julialang.org/t/type-instability-of-nested-recursive-function/78392 "2022-03-28T03:38:10Z")

</div>

I was writing some code where I need an inner function to be recursive, something like (highly simplified) function f1(x::Vector{Int64}) function g(i, val) i \<= length(x) || return g(i + 1, val) …

---

## [Task migration & data-race freedom](https://discourse.julialang.org/t/task-migration-data-race-freedom/78552)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 7\
**Last updated:** [March 28, 2022, 3:31am UTC](https://discourse.julialang.org/t/task-migration-data-race-freedom/78552 "2022-03-28T03:31:51Z")

</div>

In light of task migration, Tasks can now migrate among threads when they are re-scheduled. Previously, a Task would always run on whichever thread executed it first Can I still assume that f and g will never run con…

---

## [Displaying Parallel Progress Bars](https://discourse.julialang.org/t/displaying-parallel-progress-bars/4148)

<div class="topic-metadata">

**Author:** [@adamslc](https://discourse.julialang.org/u/adamslc)\
**Replies:** 7\
**Last updated:** [March 27, 2022, 9:14pm UTC](https://discourse.julialang.org/t/displaying-parallel-progress-bars/4148 "2022-03-27T21:14:33Z")

</div>

I need to run many simulations that will each take several hours to complete. To speed up the process, I’m going to run several of these simulations in parallel. The trouble is, I’m not very patient, and so I want some s…

---

## [How to plot a legend with many names so that some of them don't get cut](https://discourse.julialang.org/t/how-to-plot-a-legend-with-many-names-so-that-some-of-them-dont-get-cut/78568)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 2\
**Last updated:** [March 27, 2022, 8:35pm UTC](https://discourse.julialang.org/t/how-to-plot-a-legend-with-many-names-so-that-some-of-them-dont-get-cut/78568 "2022-03-27T20:35:14Z")

</div>

In a groupedbar plot, I am trying to plot the legend for a list of 30 stock names. However, using Plots, some of the bottom names in the list (e.g. WMT) do not show up in the plot legend. How may I slightly “compress”…

---

## [Extracting indexes of vectors in Julia](https://discourse.julialang.org/t/extracting-indexes-of-vectors-in-julia/78547)

<div class="topic-metadata">

**Author:** [@Leticia-maria](https://discourse.julialang.org/u/Leticia-maria)\
**Replies:** 4\
**Last updated:** [March 27, 2022, 7:59pm UTC](https://discourse.julialang.org/t/extracting-indexes-of-vectors-in-julia/78547 "2022-03-27T19:59:46Z")

</div>

How to obtain the indexes of the nonzero terms of a vector in Julia? x = \[\[3, 0, 0\], \[0, 4, 0\], \[5, 6, 0\]\] output: (\[0, 1, 2, 2\]), \[0, 1, 0, 1\])

---

## [How to wait for a thread to complete](https://discourse.julialang.org/t/how-to-wait-for-a-thread-to-complete/78546)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 3\
**Last updated:** [March 27, 2022, 7:56pm UTC](https://discourse.julialang.org/t/how-to-wait-for-a-thread-to-complete/78546 "2022-03-27T19:56:10Z")

</div>

Hi all, I have a situation where I receive a message via ZMQ and would like to perform post processing of the reply on a separate thread and then send a reply from the main thread once the post processing is complete. I…

---

## [\# of threads in Optimal Transport Package](https://discourse.julialang.org/t/of-threads-in-optimal-transport-package/78560)

<div class="topic-metadata">

**Author:** [@kadir-gunel](https://discourse.julialang.org/u/kadir-gunel)\
**Replies:** 4\
**Last updated:** [March 27, 2022, 6:38pm UTC](https://discourse.julialang.org/t/of-threads-in-optimal-transport-package/78560 "2022-03-27T18:38:25Z")

</div>

Hello, I tried to increase the # of threads in OT.jl by initializing julia with flags such as -p 16 or -t 32 but no success. I can only use 8 threads by default. Is there any way that we can increase the # of threads ? …

---

## [Will Julia be more efficient than PyTorch](https://discourse.julialang.org/t/will-julia-be-more-efficient-than-pytorch/78557)

<div class="topic-metadata">

**Author:** [@mindaslab](https://discourse.julialang.org/u/mindaslab)\
**Replies:** 1\
**Last updated:** [March 27, 2022, 5:29pm UTC](https://discourse.julialang.org/t/will-julia-be-more-efficient-than-pytorch/78557 "2022-03-27T17:29:19Z")

</div>

Hello All, I am very much interested in deep learning, but I realize that I cannot buy expensive hardware that industries use to train things like GPT-NeoX and so on.I wonder if a neural network is built and trained on…

---

## [\[ANN\] Faiss.jl, similarity search](https://discourse.julialang.org/t/ann-faiss-jl-similarity-search/78065)

<div class="topic-metadata">

**Author:** [@zsz00](https://discourse.julialang.org/u/zsz00)\
**Replies:** 18\
**Last updated:** [March 27, 2022, 3:58pm UTC](https://discourse.julialang.org/t/ann-faiss-jl-similarity-search/78065 "2022-03-27T15:58:39Z")

</div>

zsz00/Faiss.jl: Julia wrapper around the Faiss library for similarity search with PythonCall.jl (github.com) A simple Julia wrapper around the Faiss library for similarity search with PythonCall.jl . While functional …

---

## [One-dimensional NLS using MethodOfLines 'type Array has no field lhs\`](https://discourse.julialang.org/t/one-dimensional-nls-using-methodoflines-type-array-has-no-field-lhs/78543)

<div class="topic-metadata">

**Author:** [@Ruvi\_Lecamwasam](https://discourse.julialang.org/u/Ruvi_Lecamwasam)\
**Replies:** 1\
**Last updated:** [March 27, 2022, 12:27pm UTC](https://discourse.julialang.org/t/one-dimensional-nls-using-methodoflines-type-array-has-no-field-lhs/78543 "2022-03-27T12:27:26Z")

</div>

I’m trying to solve the one-dimensional nonlinear Schrodinger equation using MethodOfLines. I looked at the code on the docs: http://methodoflines.sciml.ai/dev/tutorials/brusselator/, and adapted it as: using ModelingTo…

---

## [How to interrupt async tasks?](https://discourse.julialang.org/t/how-to-interrupt-async-tasks/77745)

<div class="topic-metadata">

**Author:** [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Replies:** 7\
**Last updated:** [March 27, 2022, 11:26am UTC](https://discourse.julialang.org/t/how-to-interrupt-async-tasks/77745 "2022-03-27T11:26:53Z")

</div>

Suppose I have a few tasks synchronized by @sync and @async as show below: running = true function task() i = 0 while running println(i+=1) sleep(1) end end @sync begin @async task() …

---

## [Extremely slow n-th root of float](https://discourse.julialang.org/t/extremely-slow-n-th-root-of-float/78534)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 11\
**Last updated:** [March 27, 2022, 5:23am UTC](https://discourse.julialang.org/t/extremely-slow-n-th-root-of-float/78534 "2022-03-27T05:23:18Z")

</div>

I’m benchmarking an algorithm translated from Fortran, doing something similar to Expokit.expmv – evaluate the result of exponentiation a matrix and applying it to a vector, by expanding the exp into a polynomial series. …

---

## [How do I interpret this error?](https://discourse.julialang.org/t/how-do-i-interpret-this-error/78537)

<div class="topic-metadata">

**Author:** [@bwanab](https://discourse.julialang.org/u/bwanab)\
**Replies:** 0\
**Last updated:** [March 27, 2022, 1:20am UTC](https://discourse.julialang.org/t/how-do-i-interpret-this-error/78537 "2022-03-27T01:20:08Z")

</div>

I can’t figure what this means. It looks like it says it can’t find exactly what it’s seeing as the closest candidate. julia\> ThinkStats.probs(t) ERROR: MethodError: no method matching probs(::Main.ThinkStats.CatDist) …

---

## [Proper way to initiate an array with \`missing\`](https://discourse.julialang.org/t/proper-way-to-initiate-an-array-with-missing/8695)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 10\
**Last updated:** [March 26, 2022, 11:23pm UTC](https://discourse.julialang.org/t/proper-way-to-initiate-an-array-with-missing/8695 "2022-03-26T23:23:21Z")

</div>

pretty simple question with no documentation that I could find. is this the right way to get a 3x1 array of missings that at some point I may want to fill with with Int? julia\> x = Union{Int64, Missings.Missing}\[missing…

---

## [Probabilistic bounds-checking idea, to retain more (probabilistic) safety, and retaining most of the speed](https://discourse.julialang.org/t/probabilistic-bounds-checking-idea-to-retain-more-probabilistic-safety-and-retaining-most-of-the-speed/78515)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 2\
**Last updated:** [March 26, 2022, 8:23pm UTC](https://discourse.julialang.org/t/probabilistic-bounds-checking-idea-to-retain-more-probabilistic-safety-and-retaining-most-of-the-speed/78515 "2022-03-26T20:23:16Z")

</div>

First, I like Julia’s approach to bounds checking, it seems ideal, better than most, in fact all, languages I know of. My own idea: @inbounds could be relaxed to check say every 4th loop iteration (configurable by the u…

---

## [Julia 3 times slower than Fortran reading integer data from ASCII file](https://discourse.julialang.org/t/julia-3-times-slower-than-fortran-reading-integer-data-from-ascii-file/78516)

<div class="topic-metadata">

**Author:** [@jman87](https://discourse.julialang.org/u/jman87)\
**Replies:** 14\
**Last updated:** [March 26, 2022, 7:20pm UTC](https://discourse.julialang.org/t/julia-3-times-slower-than-fortran-reading-integer-data-from-ascii-file/78516 "2022-03-26T19:20:13Z")

</div>

Hey all, I’ve been dabbling with Julia since the 0. days. Up to point I haven’t had any real performance issues, but am now needing to read in some fairly large size files (think finite element / mesh data with millions …

---

## [Problem with package Plots](https://discourse.julialang.org/t/problem-with-package-plots/78511)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 0\
**Last updated:** [March 26, 2022, 12:34pm UTC](https://discourse.julialang.org/t/problem-with-package-plots/78511 "2022-03-26T12:34:15Z")

</div>

I have to run using Plots to run code that calls the Plots package. When I do that I get a message. The package still runs, the charts are generated normally. Still, something is not working properly. It would be best t…

---

## [Nonlinear curve fitting with weights with LsqFit](https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478)

<div class="topic-metadata">

**Author:** [@achjaj](https://discourse.julialang.org/u/achjaj)\
**Replies:** 10\
**Last updated:** [March 26, 2022, 12:22pm UTC](https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478 "2022-03-26T12:22:52Z")

</div>

Hello, I need to fit the exponential decay law to some data with weights. I tried to use LsqFit.jl, however the standard\_errors function returns too low values. I discovered it by comparing my results with my friend and…

---

## [Tell julia where R is](https://discourse.julialang.org/t/tell-julia-where-r-is/78499)

<div class="topic-metadata">

**Author:** [@wub7quxa](https://discourse.julialang.org/u/wub7quxa)\
**Replies:** 2\
**Last updated:** [March 26, 2022, 5:27am UTC](https://discourse.julialang.org/t/tell-julia-where-r-is/78499 "2022-03-26T05:27:46Z")

</div>

I run Julia in Jupyter on AWS Amazon SageMaker, where it is installed using anaconda. R Jupyter notebooks work as well, so clearly R is installed. “add RCall” in Julia’s package manager succeeds. But when I do “using RCa…

---

## [Type-instability because of @threads boxing variables](https://discourse.julialang.org/t/type-instability-because-of-threads-boxing-variables/78395)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 23\
**Last updated:** [March 25, 2022, 11:38pm UTC](https://discourse.julialang.org/t/type-instability-because-of-threads-boxing-variables/78395 "2022-03-25T23:38:29Z")

</div>

See Type-instability because of @threads boxing variables - #12 by lmiq for a more precise description of the problem. Why are allocations occurring (or being reported, at least, by @allocated) in this example, sort of…

---

## [Recommended Quickcheck library](https://discourse.julialang.org/t/recommended-quickcheck-library/78475)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 1\
**Last updated:** [March 25, 2022, 6:15pm UTC](https://discourse.julialang.org/t/recommended-quickcheck-library/78475 "2022-03-25T18:15:48Z")

</div>

Hi, is there a recommended library similary to Haskel’s QuickCheck that is still maintained? I have found QuickCheck.jl and RandomizedPropertyTest.jl but both seem abandoned. Any other recommendations? Thanks!

---

## [Combining lots of DataFrames, best approach?](https://discourse.julialang.org/t/combining-lots-of-dataframes-best-approach/78466)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 10\
**Last updated:** [March 25, 2022, 6:05pm UTC](https://discourse.julialang.org/t/combining-lots-of-dataframes-best-approach/78466 "2022-03-25T18:05:38Z")

</div>

I am wondering if there are better ways to append lots of DataFrames together in these two scenarios. # dts is a vector of lots of dataframes (\>1000) # here is a MWE version of it dts = \[DataFrame(pid=fill(string(rand(U…

---

## [How to preallocate a triangular matrix and overwrite it with cholesky!](https://discourse.julialang.org/t/how-to-preallocate-a-triangular-matrix-and-overwrite-it-with-cholesky/78463)

<div class="topic-metadata">

**Author:** [@LuZhangstat](https://discourse.julialang.org/u/LuZhangstat)\
**Replies:** 9\
**Last updated:** [March 25, 2022, 3:37pm UTC](https://discourse.julialang.org/t/how-to-preallocate-a-triangular-matrix-and-overwrite-it-with-cholesky/78463 "2022-03-25T15:37:29Z")

</div>

Hi everyone, I am trying to improve my code’s efficiency. I locate a line that might be too expensive, but I failed to figure out how to improve it. In brief, I need to save the inverse of an N by N covariance matrix of…

---

## [Use of "export" keyword](https://discourse.julialang.org/t/use-of-export-keyword/78457)

<div class="topic-metadata">

**Author:** [@iAnkiit](https://discourse.julialang.org/u/iAnkiit)\
**Replies:** 3\
**Last updated:** [March 25, 2022, 3:01pm UTC](https://discourse.julialang.org/t/use-of-export-keyword/78457 "2022-03-25T15:01:38Z")

</div>

What is the actual use of keyword “export” ? I have read julia documentation , but not very clear. What if we dont use export at all?

---

## [How to make an executable work on different machines (make a dynamic path)?](https://discourse.julialang.org/t/how-to-make-an-executable-work-on-different-machines-make-a-dynamic-path/78236)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 6\
**Last updated:** [March 25, 2022, 12:49pm UTC](https://discourse.julialang.org/t/how-to-make-an-executable-work-on-different-machines-make-a-dynamic-path/78236 "2022-03-25T12:49:00Z")

</div>

I have created a project folder TESTEXE and built an executable as below: module testexe Base.@ccallable function julia\_main()::Cint try testApp() catch Base.invokelatest(Base.display\_error, B…

---

## [Why does BenchmarkTools \`@belapsed\` make so many allocations?](https://discourse.julialang.org/t/why-does-benchmarktools-belapsed-make-so-many-allocations/78433)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 2\
**Last updated:** [March 25, 2022, 5:07am UTC](https://discourse.julialang.org/t/why-does-benchmarktools-belapsed-make-so-many-allocations/78433 "2022-03-25T05:07:24Z")

</div>

For a long time, I have been hard-coding my own benchmarks using expressions like minimum(@elapsed f() for \_ in 1:samples). It was brought to my attention that BenchmarkTools.jl does this kind of repeated sampling automa…

---

## [ANN: Package for simulation of shells and beams](https://discourse.julialang.org/t/ann-package-for-simulation-of-shells-and-beams/78429)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 0\
**Last updated:** [March 24, 2022, 10:28pm UTC](https://discourse.julialang.org/t/ann-package-for-simulation-of-shells-and-beams/78429 "2022-03-24T22:28:51Z")

</div>

The following package for finite element analysis of beams and shells has reached maturity: https://github.com/PetrKryslUCSD/FinEtoolsFlexStructures.jl Written entirely in Julia, the performance in linear shell problem…

---

## [Reversing a range of \`UInt8\`s yields an empty set](https://discourse.julialang.org/t/reversing-a-range-of-uint8-s-yields-an-empty-set/78434)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 4\
**Last updated:** [March 25, 2022, 2:24am UTC](https://discourse.julialang.org/t/reversing-a-range-of-uint8-s-yields-an-empty-set/78434 "2022-03-25T02:24:52Z")

</div>

Is this a bug or not? (v1.7.0) julia\> UInt8(1):UInt8(12) |\> collect 12-element Vector{UInt8}: 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c julia\> reverse(UInt8(1):UInt8(12)) |\> collect UInt8\[…

---

## [Advice to make getfield(::NamedTuple, ::Symbol) typestable](https://discourse.julialang.org/t/advice-to-make-getfield-namedtuple-symbol-typestable/78340)

<div class="topic-metadata">

**Author:** [@ianfiske](https://discourse.julialang.org/u/ianfiske)\
**Replies:** 19\
**Last updated:** [March 25, 2022, 12:29am UTC](https://discourse.julialang.org/t/advice-to-make-getfield-namedtuple-symbol-typestable/78340 "2022-03-25T00:29:54Z")

</div>

I have a complicated nested NamedTuple, where profiling shows that getindex on the NamedTuple is a significant source of slowness. @code\_warntype shows a type instability from getindex on that NamedTuple in the slow cal…

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

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