# General Usage

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

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

**Page:** 559

---

## [Union splitting and AbstractArray](https://discourse.julialang.org/t/union-splitting-and-abstractarray/66692)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 9\
**Last updated:** [August 19, 2021, 10:26pm UTC](https://discourse.julialang.org/t/union-splitting-and-abstractarray/66692 "2021-08-19T22:26:48Z")

</div>

How to select efficiently all types which can directly processed by write()? For scalar types I can use if v isa Real || v is a Char write(io, v) elseif ... An extension to non-scalar types like if v isa AbstractA…

---

## [Type stability for higher derivatives in ForwardDiff](https://discourse.julialang.org/t/type-stability-for-higher-derivatives-in-forwarddiff/66686)

<div class="topic-metadata">

**Author:** [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 10:07pm UTC](https://discourse.julialang.org/t/type-stability-for-higher-derivatives-in-forwarddiff/66686 "2021-08-19T22:07:56Z")

</div>

I’m trying to compute all third partial derivatives of a function using ForwardDiff, but cannot get it to be type stable and I don’t understand why. Here is a minimal example: using ForwardDiff using StaticArrays funct…

---

## [Best practices with ComponentArrays.jl](https://discourse.julialang.org/t/best-practices-with-componentarrays-jl/66064)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 1\
**Last updated:** [August 19, 2021, 7:26pm UTC](https://discourse.julialang.org/t/best-practices-with-componentarrays-jl/66064 "2021-08-19T19:26:05Z")

</div>

Suppose I have a model M with parameters θ that are arranged in a ComponentArray. Model M has several components M1 to M2 that each take a subset of components of θ. I’m wondering what’s better, balancing performance and…

---

## [Composing a function with keyword arguments](https://discourse.julialang.org/t/composing-a-function-with-keyword-arguments/66677)

<div class="topic-metadata">

**Author:** [@zekeriya.sari](https://discourse.julialang.org/u/zekeriya.sari)\
**Replies:** 9\
**Last updated:** [August 19, 2021, 6:31pm UTC](https://discourse.julialang.org/t/composing-a-function-with-keyword-arguments/66677 "2021-08-19T18:31:42Z")

</div>

Hi all, I want to wrap a function with keyword arguments. Here is what I am trying to do, # Wraps \`fk(x)\` with \`d\`, i.e. \`fn(x) = fk(d \* x)\` function wrapper(fk) function fn(x; d = 1) @show d …

---

## [Error when using fit(LinearModel,...) through GLM](https://discourse.julialang.org/t/error-when-using-fit-linearmodel-through-glm/5781)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [August 19, 2021, 6:14pm UTC](https://discourse.julialang.org/t/error-when-using-fit-linearmodel-through-glm/5781 "2021-08-19T18:14:59Z")

</div>

I want to perform a simple linear regression using this code: fit(LinearModel, @formula(Y ~ t + t2 + t3), regdata) I get the following error message: MethodError: no method matching getindex(::DataFrames.DataFrame, ::…

---

## [Managing Julia packages in a Conda environment by moving JULIA\_DEPOT](https://discourse.julialang.org/t/managing-julia-packages-in-a-conda-environment-by-moving-julia-depot/66685)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 0\
**Last updated:** [August 19, 2021, 5:55pm UTC](https://discourse.julialang.org/t/managing-julia-packages-in-a-conda-environment-by-moving-julia-depot/66685 "2021-08-19T17:55:08Z")

</div>

Julia 1.6.1 is currently in conda-forge and Julia 1.6.2 is on its way. There’s another pull request proposing to add a Conda specific JULIA\_DEPOT location, and I was wondering if anyone else had any thoughts on managing…

---

## [Weird applicable behavior](https://discourse.julialang.org/t/weird-applicable-behavior/66679)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 3:36pm UTC](https://discourse.julialang.org/t/weird-applicable-behavior/66679 "2021-08-19T15:36:21Z")

</div>

mutable struct Coords x::Float64 y::Float64 z::Float64 end Coords() = Coords(rand(), rand(), rand()) v = Coords() println(v) println(applicable(first, v)) println(first(v)) yields an (expected) error after …

---

## [How to split a matrix in a submatrix of given ranges?](https://discourse.julialang.org/t/how-to-split-a-matrix-in-a-submatrix-of-given-ranges/66642)

<div class="topic-metadata">

**Author:** [@karalis1](https://discourse.julialang.org/u/karalis1)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-to-split-a-matrix-in-a-submatrix-of-given-ranges/66642 "2021-08-19T13:48:00Z")

</div>

Hi all, I’m trying to implement an algorithm but I can’t figure it out how to split a matrix in a submatrix given some ranges I have tried with views and comprehension but didn’t succed to obtain the given ranges. Th…

---

## [Memory Allocation on Array Element Operations](https://discourse.julialang.org/t/memory-allocation-on-array-element-operations/66676)

<div class="topic-metadata">

**Author:** [@MatthiasSchneller](https://discourse.julialang.org/u/MatthiasSchneller)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 1:44pm UTC](https://discourse.julialang.org/t/memory-allocation-on-array-element-operations/66676 "2021-08-19T13:44:53Z")

</div>

Hi, I currently have the problem that i want to add elements from a Vector to other, more or less random, elements of a matrix. Because i have to do this a lot of times i wanted to improve the performance of it. And tha…

---

## [Jldoctest: expecting (incorrectly) an empty output](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 3\
**Last updated:** [August 19, 2021, 1:33pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671 "2021-08-19T13:33:07Z")

</div>

I am getting the error below in a jldoctest. The command, when copy/pasted, works perfectly fine. What can be wrong here? #\`\`\`jldoctest │ julia\> using CellListMap │ │ julia\> box = Box(\[ 10 0 0 │ …

---

## [Detect User Language?](https://discourse.julialang.org/t/detect-user-language/66670)

<div class="topic-metadata">

**Author:** [@Daneel](https://discourse.julialang.org/u/Daneel)\
**Replies:** 3\
**Last updated:** [August 19, 2021, 1:13pm UTC](https://discourse.julialang.org/t/detect-user-language/66670 "2021-08-19T13:13:47Z")

</div>

Is there a way to detect the default language that the user speaks? Presumably this would be the current operating system language. I’m trying to tailor the outputs to the user. It would be great if it were a constant l…

---

## [Speed comparison matrix multiplication in Julia](https://discourse.julialang.org/t/speed-comparison-matrix-multiplication-in-julia/66656)

<div class="topic-metadata">

**Author:** [@sivakon](https://discourse.julialang.org/u/sivakon)\
**Replies:** 45\
**Last updated:** [August 19, 2021, 12:33pm UTC](https://discourse.julialang.org/t/speed-comparison-matrix-multiplication-in-julia/66656 "2021-08-19T12:33:30Z")

</div>

Optimized version in Julia. (126ms opt. Julia vs. 676ms in Jax - Int32) (521ms opt. Julia vs. 2.2s in Jax - Int64) Using tullio Int32 using Tullio, BenchmarkTools, LoopVectorization # Row major a = Array(reshape(Int32…

---

## [LMI, Control system, Robust Control Adaptive Controller](https://discourse.julialang.org/t/lmi-control-system-robust-control-adaptive-controller/65626)

<div class="topic-metadata">

**Author:** [@Asifalimaitlo\_Asifal](https://discourse.julialang.org/u/Asifalimaitlo_Asifal)\
**Replies:** 13\
**Last updated:** [August 19, 2021, 9:31am UTC](https://discourse.julialang.org/t/lmi-control-system-robust-control-adaptive-controller/65626 "2021-08-19T09:31:23Z")

</div>

Piecewise gain-scheduled L2 control

---

## [Verify generated images during automated testing](https://discourse.julialang.org/t/verify-generated-images-during-automated-testing/66389)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 3\
**Last updated:** [August 19, 2021, 11:20am UTC](https://discourse.julialang.org/t/verify-generated-images-during-automated-testing/66389 "2021-08-19T11:20:25Z")

</div>

I am looking for a way to verify images that are auto-generated during CI/automated testing. For example, I would like to run a simulation, plot the result with Plots.jl or Makie.jl, and then verify the resulting PNG fil…

---

## [Is there a "select case" equivalent in Julia?](https://discourse.julialang.org/t/is-there-a-select-case-equivalent-in-julia/66516)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 21\
**Last updated:** [August 19, 2021, 10:58am UTC](https://discourse.julialang.org/t/is-there-a-select-case-equivalent-in-julia/66516 "2021-08-19T10:58:58Z")

</div>

Here is a small Fortran subroutine, with select case, subroutine steps(it) integer(kind=i8) :: it select case (imode) case (11) call step11(it) case (12) call step12(it) case default write (6,'(''Illegal imode …

---

## [DynamicHMC: Reached maximum number of iterations while bisecting interval for epsilon](https://discourse.julialang.org/t/dynamichmc-reached-maximum-number-of-iterations-while-bisecting-interval-for-epsilon/63595)

<div class="topic-metadata">

**Author:** [@kai](https://discourse.julialang.org/u/kai)\
**Replies:** 8\
**Last updated:** [August 19, 2021, 10:56am UTC](https://discourse.julialang.org/t/dynamichmc-reached-maximum-number-of-iterations-while-bisecting-interval-for-epsilon/63595 "2021-08-19T10:56:11Z")

</div>

@Tamas\_Papp I saw there is a previous thread discussing this problem, but I don’t quite get the solution so I’m starting a new one. “Reached maximum number of iterations while bisecting interval for ϵ.” I’ve seen this…

---

## [Is \`@async\` memory safe?](https://discourse.julialang.org/t/is-async-memory-safe/66558)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 13\
**Last updated:** [August 19, 2021, 7:14am UTC](https://discourse.julialang.org/t/is-async-memory-safe/66558 "2021-08-19T07:14:33Z")

</div>

The page of the manual on multi-threading warns about memory-unsafe operations in data race conditions, and gives the advice of using locks or atomic operations on Threads.Atomic objects to work around that problem. I g…

---

## [How to unpack log.gz to an array or CSv file?](https://discourse.julialang.org/t/how-to-unpack-log-gz-to-an-array-or-csv-file/66657)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 0\
**Last updated:** [August 19, 2021, 6:44am UTC](https://discourse.julialang.org/t/how-to-unpack-log-gz-to-an-array-or-csv-file/66657 "2021-08-19T06:44:53Z")

</div>

How to unpack log.gz to an array or CSv file ? The separators are spaces and in the data there are sometimes strings closed in “some text” ? 5.252.230.133 - - \[04/Aug/2021:23:49:50 +0200\] "POST /wp-cron.php?doing\_wp\_cro…

---

## [Allocation-free type hiding?](https://discourse.julialang.org/t/allocation-free-type-hiding/66609)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 14\
**Last updated:** [August 19, 2021, 5:30am UTC](https://discourse.julialang.org/t/allocation-free-type-hiding/66609 "2021-08-19T05:30:37Z")

</div>

I’m trying to reduce latency in a package, and was intrigued by the mention of “type hiding” in the Dataframes.jl Juliacon talk by @bkamins (State of DataFrames.jl - YouTube). As I understand it, type hiding consists of…

---

## [How can I avoid insatisfient random variable in Turing.jl?](https://discourse.julialang.org/t/how-can-i-avoid-insatisfient-random-variable-in-turing-jl/66397)

<div class="topic-metadata">

**Author:** [@dddd1007](https://discourse.julialang.org/u/dddd1007)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 2:52am UTC](https://discourse.julialang.org/t/how-can-i-avoid-insatisfient-random-variable-in-turing-jl/66397 "2021-08-19T02:52:41Z")

</div>

Hi! I want to ask how to keep the suitable beta distribution parameters in the HMM model in Turing.jl . The details as follow: I am trying to implement Bayesian Learner Model of Tim Behrens. It’s a model like this: W…

---

## [How to do format write correctly?](https://discourse.julialang.org/t/how-to-do-format-write-correctly/66648)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 2\
**Last updated:** [August 19, 2021, 1:51am UTC](https://discourse.julialang.org/t/how-to-do-format-write-correctly/66648 "2021-08-19T01:51:53Z")

</div>

I am sorry another stupid question, I read the IO part of the Julia documents I/O and Network · The Julia Language, but I am still too stupid to do the following simply thing. For example, the short illustration code be…

---

## [Accessing profiling data programmatically](https://discourse.julialang.org/t/accessing-profiling-data-programmatically/66355)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 0\
**Last updated:** [August 13, 2021, 7:49pm UTC](https://discourse.julialang.org/t/accessing-profiling-data-programmatically/66355 "2021-08-13T19:49:29Z")

</div>

I did not find an example of querying Julia profiling data for e.g. the number of samples that hit a given function. I want to post what I’m using in case it’s useful to anyone searching: using Profile using FlameGraphs…

---

## [What is the advantage of Julia over Fortran?](https://discourse.julialang.org/t/what-is-the-advantage-of-julia-over-fortran/65964)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 132\
**Last updated:** [August 18, 2021, 11:06pm UTC](https://discourse.julialang.org/t/what-is-the-advantage-of-julia-over-fortran/65964 "2021-08-18T23:06:03Z")

</div>

I am from Fortran (high performance modern Fortran) to Julia. May I just straightforwardly ask a question to you guys, so, What is the advantage of Julia over Fortran? I mean, modern Fortran seems is not that bad, and…

---

## [Pinning LinearAlgebra in Julia 1.6.2](https://discourse.julialang.org/t/pinning-linearalgebra-in-julia-1-6-2/66596)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 13\
**Last updated:** [August 18, 2021, 9:27pm UTC](https://discourse.julialang.org/t/pinning-linearalgebra-in-julia-1-6-2/66596 "2021-08-18T21:27:45Z")

</div>

Hi, I am testing two packages in Julia 1.6.2 (TSAnalysis.jl and a new private package in the same area), as I have been using them with the LTS version until now. They seem to be working fine and pass all unit tests exc…

---

## [Discrepancy betwteen \`htop\` and \`sum(map(x-\>sizeof(x),names(Main)))\`](https://discourse.julialang.org/t/discrepancy-betwteen-htop-and-sum-map-x-sizeof-x-names-main/66629)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [August 18, 2021, 8:59pm UTC](https://discourse.julialang.org/t/discrepancy-betwteen-htop-and-sum-map-x-sizeof-x-names-main/66629 "2021-08-18T20:59:44Z")

</div>

1. Check the total size of stuff julia knows about: sizeof I get a negligible value when I check the size of the environment: GC.gc() julia\> sum(map(x-\>sizeof(x),names(Main)))/1e6 # total size in megabytes 0.000598 2. …

---

## [Instead of OutOfMemory Error being thrown, my OS (Ubuntu) is killing the julia process](https://discourse.julialang.org/t/instead-of-outofmemory-error-being-thrown-my-os-ubuntu-is-killing-the-julia-process/66612)

<div class="topic-metadata">

**Author:** [@Antell](https://discourse.julialang.org/u/Antell)\
**Replies:** 6\
**Last updated:** [August 18, 2021, 9:11pm UTC](https://discourse.julialang.org/t/instead-of-outofmemory-error-being-thrown-my-os-ubuntu-is-killing-the-julia-process/66612 "2021-08-18T21:11:11Z")

</div>

I am writing a process that loads file into memory, does some operations, and then moves to the next file. Some large files do not fit into my RAM, and I would like to catch the OOM exception and skip the file. However, …

---

## [Save complex state in function and reuse on next function call](https://discourse.julialang.org/t/save-complex-state-in-function-and-reuse-on-next-function-call/66538)

<div class="topic-metadata">

**Author:** [@DorianT](https://discourse.julialang.org/u/DorianT)\
**Replies:** 4\
**Last updated:** [August 18, 2021, 4:32pm UTC](https://discourse.julialang.org/t/save-complex-state-in-function-and-reuse-on-next-function-call/66538 "2021-08-18T16:32:09Z")

</div>

I have the following function makebatch that creates batches for my model from a text file. The file is processed line-by-line and sometimes processing a line will lead the output to exceed the desired batch size. In thi…

---

## [Speeding up sort along an array dimension](https://discourse.julialang.org/t/speeding-up-sort-along-an-array-dimension/66468)

<div class="topic-metadata">

**Author:** [@johnbb](https://discourse.julialang.org/u/johnbb)\
**Replies:** 11\
**Last updated:** [August 18, 2021, 1:33pm UTC](https://discourse.julialang.org/t/speeding-up-sort-along-an-array-dimension/66468 "2021-08-18T13:33:11Z")

</div>

I have large arrays which I would like to sort along a single dimension of small size as in the example below. Any suggestions to increase performance would be welcome. using BenchmarkTools a = rand(Float32, 1000, 1000,…

---

## [Validity of package documentation and examples](https://discourse.julialang.org/t/validity-of-package-documentation-and-examples/66217)

<div class="topic-metadata">

**Author:** [@JOST](https://discourse.julialang.org/u/JOST)\
**Replies:** 20\
**Last updated:** [August 18, 2021, 1:21pm UTC](https://discourse.julialang.org/t/validity-of-package-documentation-and-examples/66217 "2021-08-18T13:21:10Z")

</div>

Is this really right? Julia packages are rather messy and instructions and exampels for using packages seems not quite able to be in step with modifications.

---

## [Running Julia with native Multithreading vs in Seperate Processes](https://discourse.julialang.org/t/running-julia-with-native-multithreading-vs-in-seperate-processes/66594)

<div class="topic-metadata">

**Author:** [@Paul\_Depping](https://discourse.julialang.org/u/Paul_Depping)\
**Replies:** 1\
**Last updated:** [August 18, 2021, 10:58am UTC](https://discourse.julialang.org/t/running-julia-with-native-multithreading-vs-in-seperate-processes/66594 "2021-08-18T10:58:55Z")

</div>

Hello, I’ve measured the performance of a Script which: Reads from a file of some binary format Does a binary search of what it read within a big sorted list containing every value and then fills in a Vector{UInt8} th…

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

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