# General Usage

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

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

**Page:** 280

---

## [Stability of Julia between versions](https://discourse.julialang.org/t/stability-of-julia-between-versions/100001)

<div class="topic-metadata">

**Author:** [@JuliaBoomer](https://discourse.julialang.org/u/JuliaBoomer)\
**Replies:** 12\
**Last updated:** [June 14, 2023, 10:04pm UTC](https://discourse.julialang.org/t/stability-of-julia-between-versions/100001 "2023-06-14T22:04:53Z")

</div>

Hello, I am working on an optimization tool coded in Julia in its version 1.3.1. Until a few months ago, I regularly encountered stability issues, with the tool apparently becoming obsolete after some updates. I would l…

---

## [Automatic transformation of constrained distributions in Turing.jl](https://discourse.julialang.org/t/automatic-transformation-of-constrained-distributions-in-turing-jl/100369)

<div class="topic-metadata">

**Author:** [@sandy6502](https://discourse.julialang.org/u/sandy6502)\
**Replies:** 0\
**Last updated:** [June 14, 2023, 9:53pm UTC](https://discourse.julialang.org/t/automatic-transformation-of-constrained-distributions-in-turing-jl/100369 "2023-06-14T21:53:11Z")

</div>

This is a question about automatic transformation of constrained distributions. The docs on compiler design say “Random variables whose distributions have a constrained support are transformed using a bijector from Bije…

---

## [Find whether a Julia script has the output redirected to the screen or a pipe?](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 2\
**Last updated:** [June 14, 2023, 9:48pm UTC](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365 "2023-06-14T21:48:31Z")

</div>

How do I find whether a Julia script running in the terminal has the output (stdout) redirected to the screen or a pipe? $ ./julia\_script # outputs to the terminal $ ./julia\_script | command # pipes the output

---

## [Sorted Attributes in XML.jl?](https://discourse.julialang.org/t/sorted-attributes-in-xml-jl/100168)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 8\
**Last updated:** [June 14, 2023, 7:59pm UTC](https://discourse.julialang.org/t/sorted-attributes-in-xml-jl/100168 "2023-06-14T19:59:54Z")

</div>

Hello! I saw the newly released XML.jl and I am really excited about it. I wonder if it is possible to “enforce” attribute ordering? I have a case in which I want to produce and XML which is meant to be both human read…

---

## [How to select rows of differently sized matrices based on an approximate value within a column of each matrix](https://discourse.julialang.org/t/how-to-select-rows-of-differently-sized-matrices-based-on-an-approximate-value-within-a-column-of-each-matrix/100343)

<div class="topic-metadata">

**Author:** [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Replies:** 6\
**Last updated:** [June 14, 2023, 7:27pm UTC](https://discourse.julialang.org/t/how-to-select-rows-of-differently-sized-matrices-based-on-an-approximate-value-within-a-column-of-each-matrix/100343 "2023-06-14T19:27:35Z")

</div>

A bit hard to explain in the title. I have saved the output of hundreds of runs from a solver (from DifferentialEquations). The overall run time is the same between the runs (start and end time are the same), but the sol…

---

## [Makie: Unable to position Legend](https://discourse.julialang.org/t/makie-unable-to-position-legend/99769)

<div class="topic-metadata">

**Author:** [@VictorSeven](https://discourse.julialang.org/u/VictorSeven)\
**Replies:** 3\
**Last updated:** [June 14, 2023, 7:21pm UTC](https://discourse.julialang.org/t/makie-unable-to-position-legend/99769 "2023-06-14T19:21:20Z")

</div>

Hi all, I am trying to get a figure done with Makie. I am having trouble setting the position of my legend so it does not intersect with the lines. I have checked Legend · Makie , but that only says that I can use combi…

---

## [Overload in place =](https://discourse.julialang.org/t/overload-in-place/100331)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 5\
**Last updated:** [June 14, 2023, 3:50pm UTC](https://discourse.julialang.org/t/overload-in-place/100331 "2023-06-14T15:50:08Z")

</div>

I have a custom type that looks like this struct foo{T} A1::Array{T} A2::Array{T} end function Base.:+(x:: foo, y:: foo) return foo(x.A1 + y.A1, x.A2 + y.A2) end function Base.:.=(x:: foo, y:: foo) x.A1 .= y.A1 x…

---

## [Intercept stdin to capture output from ANSI code](https://discourse.julialang.org/t/intercept-stdin-to-capture-output-from-ansi-code/100330)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 1\
**Last updated:** [June 14, 2023, 3:36pm UTC](https://discourse.julialang.org/t/intercept-stdin-to-capture-output-from-ansi-code/100330 "2023-06-14T15:36:29Z")

</div>

I am informed by this post: linux - How can I get position of cursor in terminal? - Stack Overflow When I run print("\\x1b\[6n"), the current cursor position is written into stdin. However, the start is an escape sequence…

---

## [What is the role of Ref in this function and why is it faster than the alternative?](https://discourse.julialang.org/t/what-is-the-role-of-ref-in-this-function-and-why-is-it-faster-than-the-alternative/100319)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 6\
**Last updated:** [June 14, 2023, 3:15pm UTC](https://discourse.julialang.org/t/what-is-the-role-of-ref-in-this-function-and-why-is-it-faster-than-the-alternative/100319 "2023-06-14T15:15:41Z")

</div>

This function converts a categorical vector to an index: function convert\_factor\_to\_index(cat\_vec::CategoricalVector)::Vector{Int} levs = levels(cat\_vec) int\_vec::Vector{Int} = findfirst.(isequal.(cat\_v…

---

## [\`\]test Package\` errors, but \`include(test\_script)\` succeeds](https://discourse.julialang.org/t/test-package-errors-but-include-test-script-succeeds/100326)

<div class="topic-metadata">

**Author:** [@jtackm](https://discourse.julialang.org/u/jtackm)\
**Replies:** 3\
**Last updated:** [June 14, 2023, 2:48pm UTC](https://discourse.julialang.org/t/test-package-errors-but-include-test-script-succeeds/100326 "2023-06-14T14:48:23Z")

</div>

When testing a package (FlashWeave.jl) via \]test FlashWeave, I’m getting errors related to internal matrix computations (only reliant on SparseArrays.jl), but if I instead manually include(\<test\_script\>) the same test sc…

---

## [Test whether an iterable is strictly increasing](https://discourse.julialang.org/t/test-whether-an-iterable-is-strictly-increasing/100282)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [June 14, 2023, 1:56pm UTC](https://discourse.julialang.org/t/test-whether-an-iterable-is-strictly-increasing/100282 "2023-06-14T13:56:46Z")

</div>

Is there a simple way to test if an iterable (not necessarily instantiated) is strictly increasing? (Cf this long topic on why issorted(itr, lt = \<) does not do this). The solution has to be non-allocating. Simplest I c…

---

## [Speed of evolution of Julia and backwards compatibility](https://discourse.julialang.org/t/speed-of-evolution-of-julia-and-backwards-compatibility/100329)

<div class="topic-metadata">

**Author:** [@schaefer0](https://discourse.julialang.org/u/schaefer0)\
**Replies:** 5\
**Last updated:** [June 14, 2023, 1:39pm UTC](https://discourse.julialang.org/t/speed-of-evolution-of-julia-and-backwards-compatibility/100329 "2023-06-14T13:39:53Z")

</div>

Hi, My context and observations: I’m new to julia (with a goal towards using julia to push data processing to the edge of distributed networks and close to sensors) and as such, first look to language tutorials, and to…

---

## [Start Julia process on Raspberry Pi over SSH, run arbitrary code, get return values on host](https://discourse.julialang.org/t/start-julia-process-on-raspberry-pi-over-ssh-run-arbitrary-code-get-return-values-on-host/100087)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 6\
**Last updated:** [June 13, 2023, 9:15am UTC](https://discourse.julialang.org/t/start-julia-process-on-raspberry-pi-over-ssh-run-arbitrary-code-get-return-values-on-host/100087 "2023-06-13T09:15:43Z")

</div>

I just stumbled over Running commands over ssh - #8 by jw3126, which had me thinking: Could I use Distributed to launch a Julia process on a Raspberry Pi, and then use Distributed.remotecall to run arbitrary commands th…

---

## [How to approximate a noisy spectrum](https://discourse.julialang.org/t/how-to-approximate-a-noisy-spectrum/99519)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 35\
**Last updated:** [June 14, 2023, 11:48am UTC](https://discourse.julialang.org/t/how-to-approximate-a-noisy-spectrum/99519 "2023-06-14T11:48:04Z")

</div>

I have a noisy spectrum, and I want to get a -3db frequency and a -10db frequency somewhat accurately. It looks like this: How would you approach this task? Which approximation method and/or package would you use? (N…

---

## [Parallelizing file processing with the least amount of overhead](https://discourse.julialang.org/t/parallelizing-file-processing-with-the-least-amount-of-overhead/100169)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 2\
**Last updated:** [June 14, 2023, 9:58am UTC](https://discourse.julialang.org/t/parallelizing-file-processing-with-the-least-amount-of-overhead/100169 "2023-06-14T09:58:28Z")

</div>

Hey all! I wrote ViewReader a while ago and now thought adding some parallel file processing might be fun. ViewReader reads UInt8 (chars) to a buffer array so each thread could have its own buffer array. This might be ne…

---

## [Code associated with \`invoke\`](https://discourse.julialang.org/t/code-associated-with-invoke/100109)

<div class="topic-metadata">

**Author:** [@willtebbutt](https://discourse.julialang.org/u/willtebbutt)\
**Replies:** 4\
**Last updated:** [June 14, 2023, 9:41am UTC](https://discourse.julialang.org/t/code-associated-with-invoke/100109 "2023-06-14T09:41:29Z")

</div>

Is it possible to obtain the code associated with an invoke call? Specifically, if I were to write: sin(5.0) I know that I can get access to one of various representations of the code via code\_lowered, code\_typed, etc…

---

## [Benchmarking Fallible Code](https://discourse.julialang.org/t/benchmarking-fallible-code/97845)

<div class="topic-metadata">

**Author:** [@AlexanderNenninger](https://discourse.julialang.org/u/AlexanderNenninger)\
**Replies:** 3\
**Last updated:** [June 14, 2023, 8:33am UTC](https://discourse.julialang.org/t/benchmarking-fallible-code/97845 "2023-06-14T08:33:25Z")

</div>

Is there a way to indicate failure in benchmarked code using BenchmarkTools? Say we have the following function using Random function mayfail() if rand() \< 0.1 throw(ErrorException("┻━┻︵ \\(°□°)/ ︵ ┻━┻")) …

---

## [How to enable vectorized fma instruction for multiply-add vectors?](https://discourse.julialang.org/t/how-to-enable-vectorized-fma-instruction-for-multiply-add-vectors/100219)

<div class="topic-metadata">

**Author:** [@xinwu](https://discourse.julialang.org/u/xinwu)\
**Replies:** 10\
**Last updated:** [June 14, 2023, 8:31am UTC](https://discourse.julialang.org/t/how-to-enable-vectorized-fma-instruction-for-multiply-add-vectors/100219 "2023-06-14T08:31:02Z")

</div>

Hi, the vectorized fma instructions (unrolled by 4x) can easily be generated for the C code below via clang -Ofast -S -Wall -std=c11 -march=skylake vecfma.c. void vecfma(float \* restrict c, float \* restrict a, float \* …

---

## [Include many files and call the same function from each file in a loop but got wrong result](https://discourse.julialang.org/t/include-many-files-and-call-the-same-function-from-each-file-in-a-loop-but-got-wrong-result/100309)

<div class="topic-metadata">

**Author:** [@YiboXia](https://discourse.julialang.org/u/YiboXia)\
**Replies:** 11\
**Last updated:** [June 14, 2023, 7:51am UTC](https://discourse.julialang.org/t/include-many-files-and-call-the-same-function-from-each-file-in-a-loop-but-got-wrong-result/100309 "2023-06-14T07:51:06Z")

</div>

Hi guys! I have three .jl files, which contains a test() function like this: 1.jl: function test() Dict(\[("A", 1), ("B", 2)\]) end 2.jl: function test() Dict(\[("A", 1), ("B", 2), ("C", 3)\]) end 3.jl: function t…

---

## [Bug about reloading a package](https://discourse.julialang.org/t/bug-about-reloading-a-package/100193)

<div class="topic-metadata">

**Author:** [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Replies:** 21\
**Last updated:** [June 14, 2023, 7:33am UTC](https://discourse.julialang.org/t/bug-about-reloading-a-package/100193 "2023-06-14T07:33:39Z")

</div>

I just found that in the latest version v.1.9.×, reloading a function of a package alters the original behavior of the same function of the package when being called independently. For instance, define a module “test” …

---

## [Import only when code used?](https://discourse.julialang.org/t/import-only-when-code-used/100266)

<div class="topic-metadata">

**Author:** [@nharr](https://discourse.julialang.org/u/nharr)\
**Replies:** 5\
**Last updated:** [June 14, 2023, 2:13am UTC](https://discourse.julialang.org/t/import-only-when-code-used/100266 "2023-06-14T02:13:40Z")

</div>

Is there a way to import a module only if certain code is used? I ideally I would put it in a function, but it’s not allowed: function initialize() using A # create objects using functionality from A # to b…

---

## [Optimzing many linear solves](https://discourse.julialang.org/t/optimzing-many-linear-solves/100304)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 2\
**Last updated:** [June 14, 2023, 1:59am UTC](https://discourse.julialang.org/t/optimzing-many-linear-solves/100304 "2023-06-14T01:59:59Z")

</div>

I have a function that runs many linear solves on subsets of columns from a matrix I give it. Something like: function score(data, parents, child) #Subset columns from the data matrix @views begin X = d…

---

## [How to get the derivative of an interpolated function?](https://discourse.julialang.org/t/how-to-get-the-derivative-of-an-interpolated-function/100272)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [June 13, 2023, 11:26pm UTC](https://discourse.julialang.org/t/how-to-get-the-derivative-of-an-interpolated-function/100272 "2023-06-13T23:26:40Z")

</div>

I have the following code: using DataInterpolations Cp=\[0.024384377390186646,0.03811829845979822,0.05731175742000688,0.0803120051369546,0.10526323380995135,0.1312349486430945, 0.1588590278697544,0.1882995422205645,…

---

## [A system of PDE and ODE](https://discourse.julialang.org/t/a-system-of-pde-and-ode/100290)

<div class="topic-metadata">

**Author:** [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)\
**Replies:** 1\
**Last updated:** [June 13, 2023, 11:22pm UTC](https://discourse.julialang.org/t/a-system-of-pde-and-ode/100290 "2023-06-13T23:22:47Z")

</div>

Is PINN capable of solving a time dependent system consisting of a PDE and an ODE? for example if there is a system like below: eq = \[A \* Dt(u1(t,x)) ~ B \* Dx(u(t,x)) - C\* Dt(u2(t)), Dt(u2(t)) ~ D \* u2(t) \* exp(E \* …

---

## [When using channels, errors do not get raised, and computation stalls](https://discourse.julialang.org/t/when-using-channels-errors-do-not-get-raised-and-computation-stalls/100291)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 3\
**Last updated:** [June 13, 2023, 8:18pm UTC](https://discourse.julialang.org/t/when-using-channels-errors-do-not-get-raised-and-computation-stalls/100291 "2023-06-13T20:18:54Z")

</div>

This is intended behavior, a known issue, or an unknown bug? julia\> function test() buff = Channel{Int}(3) for \_ in 1:3 put!(buff, 0) end @sync for \_ in 1:3…

---

## [Multithreading with shared memory caches](https://discourse.julialang.org/t/multithreading-with-shared-memory-caches/100194)

<div class="topic-metadata">

**Author:** [@joaquinpelle](https://discourse.julialang.org/u/joaquinpelle)\
**Replies:** 27\
**Last updated:** [June 13, 2023, 6:46pm UTC](https://discourse.julialang.org/t/multithreading-with-shared-memory-caches/100194 "2023-06-13T18:46:25Z")

</div>

Hi there, I have a loop that uses a cache array to avoid excessive memory allocations. The structure is captured in the following example: A = rand(10000) B = similar(A) cache = zeros(3) for i in eachindex(A) f!(ca…

---

## [Zygote.jl: How to get the gradient of sparse matrix](https://discourse.julialang.org/t/zygote-jl-how-to-get-the-gradient-of-sparse-matrix/59067)

<div class="topic-metadata">

**Author:** [@Richard-Li](https://discourse.julialang.org/u/Richard-Li)\
**Replies:** 11\
**Last updated:** [June 13, 2023, 5:17pm UTC](https://discourse.julialang.org/t/zygote-jl-how-to-get-the-gradient-of-sparse-matrix/59067 "2023-06-13T17:17:20Z")

</div>

Hi there, I am trying to differentiate through sparse matrix, and here is the MWE: using LinearAlgebra using SparseArrays using ChainRulesCore using Zygote Zygote.@adjoint function SparseMatrixCSC{T,N}(arr) where {T,N}…

---

## [How to use \`precondprep\` with \`Optim.jl\`?](https://discourse.julialang.org/t/how-to-use-precondprep-with-optim-jl/100288)

<div class="topic-metadata">

**Author:** [@fph](https://discourse.julialang.org/u/fph)\
**Replies:** 0\
**Last updated:** [June 13, 2023, 3:57pm UTC](https://discourse.julialang.org/t/how-to-use-precondprep-with-optim-jl/100288 "2023-06-13T15:57:13Z")

</div>

How do I use precondprep within Optim.jl to use a preconditioner that changes at each step? The results of the function seem to be ignored in my attempts. Example: using Optim res = optimize(x-\>(x\[1\]-1)^4 + x\[2\]^2, \[2.;…

---

## [Is there an attribute to shorten the arrow tail at the tail?](https://discourse.julialang.org/t/is-there-an-attribute-to-shorten-the-arrow-tail-at-the-tail/99982)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 1\
**Last updated:** [June 13, 2023, 3:08pm UTC](https://discourse.julialang.org/t/is-there-an-attribute-to-shorten-the-arrow-tail-at-the-tail/99982 "2023-06-13T15:08:34Z")

</div>

I’m reading Eugenia Cheng’s book The Joy of Abstraction - An Exploration of Math, Category Theory, and Life. On page 61 there is an interesting diagram of all the order permutations of the multiplication 2 \* 3 \* 5 = 30 t…

---

## [Dictionary for random effects in MultiLevel.jl model](https://discourse.julialang.org/t/dictionary-for-random-effects-in-multilevel-jl-model/24515)

<div class="topic-metadata">

**Author:** [@spinkney](https://discourse.julialang.org/u/spinkney)\
**Replies:** 1\
**Last updated:** [June 13, 2023, 2:47pm UTC](https://discourse.julialang.org/t/dictionary-for-random-effects-in-multilevel-jl-model/24515 "2023-06-13T14:47:40Z")

</div>

Coming from an R background and lme4. I have 210 market\_no’s and I’m fitting a logistic regression with a varying intercept on market\_no’s. I can’t seem to find the match between the market\_no’s and the fit random effect…

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

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