# General Usage

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

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

**Page:** 100

---

## [Linestyles look the same in legend](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170)

<div class="topic-metadata">

**Author:** [@bast](https://discourse.julialang.org/u/bast)\
**Replies:** 5\
**Last updated:** [December 29, 2024, 11:16pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170 "2024-12-29T23:16:13Z")

</div>

After increasing the linewidth the linestyles in the legend are indistinguishable: using Plots testplt = plot(0:0.1:1, rand(11), label="dashdot", ls=:dashdot, color=:black, lw=4) plot!(0:0.1:1, rand(11), label="dash", …

---

## [Optimization of the use of observables and globals in Makie (from script to @main function)](https://discourse.julialang.org/t/optimization-of-the-use-of-observables-and-globals-in-makie-from-script-to-main-function/124258)

<div class="topic-metadata">

**Author:** [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Replies:** 3\
**Last updated:** [December 29, 2024, 8:54pm UTC](https://discourse.julialang.org/t/optimization-of-the-use-of-observables-and-globals-in-makie-from-script-to-main-function/124258 "2024-12-29T20:54:33Z")

</div>

I am trying to make my Makie GUI run faster and allocate less. I have just upgraded to Julia 1.11.2 and thought it was a good opportunity to use function (@main) in other words, wrap all my global scope code into a funct…

---

## [Recursion base vs hand-made recursion](https://discourse.julialang.org/t/recursion-base-vs-hand-made-recursion/124235)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 13\
**Last updated:** [December 29, 2024, 6:07pm UTC](https://discourse.julialang.org/t/recursion-base-vs-hand-made-recursion/124235 "2024-12-29T18:07:17Z")

</div>

Trying to solve the problem d17 of this year’s AOC, I found that, among the proposed solutions, the most efficient seems to be the one that uses recursion. for example, compared to an iterative one that works on the sam…

---

## [Julia runs slower after many loop iterations (solve ODE problem)](https://discourse.julialang.org/t/julia-runs-slower-after-many-loop-iterations-solve-ode-problem/124238)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 3\
**Last updated:** [December 29, 2024, 4:00am UTC](https://discourse.julialang.org/t/julia-runs-slower-after-many-loop-iterations-solve-ode-problem/124238 "2024-12-29T04:00:38Z")

</div>

Hello, I need to perform optimization of many groups of ODE problems. The optimization time required for the first few groups is about 20 minutes, but after completing multiple optimizations, the time required gradually …

---

## [Is there a function in Base that determines the most specific type?](https://discourse.julialang.org/t/is-there-a-function-in-base-that-determines-the-most-specific-type/124215)

<div class="topic-metadata">

**Author:** [@tqml](https://discourse.julialang.org/u/tqml)\
**Replies:** 1\
**Last updated:** [December 27, 2024, 9:38pm UTC](https://discourse.julialang.org/t/is-there-a-function-in-base-that-determines-the-most-specific-type/124215 "2024-12-27T21:38:31Z")

</div>

I’m currently wondering if there is a function anywhere in Base or the standard library that figures out the most specific type element for a given type (e.g. like multiple dispatch does). I would like to have a functio…

---

## [Kahan summation in \`sum\`?](https://discourse.julialang.org/t/kahan-summation-in-sum/102723)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 13\
**Last updated:** [December 29, 2024, 1:04am UTC](https://discourse.julialang.org/t/kahan-summation-in-sum/102723 "2024-12-29T01:04:03Z")

</div>

I was under the impression that sum(itr) uses Kahan summation, but after inspecting the Julia repo it appears that it calls mapreduce(identity, add\_sum, itr). And add\_sum is basically just + with some promotions for smal…

---

## [Displaying plots alongside each other in Pluto](https://discourse.julialang.org/t/displaying-plots-alongside-each-other-in-pluto/124116)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 4\
**Last updated:** [December 28, 2024, 11:57am UTC](https://discourse.julialang.org/t/displaying-plots-alongside-each-other-in-pluto/124116 "2024-12-28T11:57:14Z")

</div>

I have made plots in VegaLite. I want to display the plots alongside each other in a pluto notebook. The standard way to do this would be to combine the plots as below Plots.plot(plot1, plot2, layout = (2,1)) but that …

---

## [SLURM manager: one node with multiple tasks](https://discourse.julialang.org/t/slurm-manager-one-node-with-multiple-tasks/124173)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.julialang.org/u/kerim)\
**Replies:** 2\
**Last updated:** [December 28, 2024, 11:45am UTC](https://discourse.julialang.org/t/slurm-manager-one-node-with-multiple-tasks/124173 "2024-12-28T11:45:25Z")

</div>

Hi, I have access to a single node with many 24 cores. I want Julia to treat that node as 4 workers with 6 cores per each worker. My attempt is: using Distributed, ClusterManagers addprocs(SlurmManager(1), nodes=1, n…

---

## [Don't understand why code runs out of memory and crashes](https://discourse.julialang.org/t/dont-understand-why-code-runs-out-of-memory-and-crashes/123559)

<div class="topic-metadata">

**Author:** [@Davide98888](https://discourse.julialang.org/u/Davide98888)\
**Replies:** 29\
**Last updated:** [December 27, 2024, 9:42pm UTC](https://discourse.julialang.org/t/dont-understand-why-code-runs-out-of-memory-and-crashes/123559 "2024-12-27T21:42:15Z")

</div>

Hello all We are having a fantastic experience with Julia, but then had a confusing experience. I am doing a simulation study, multithreaded, and eventually Julia runs out of memory and crashes. This happens especially …

---

## [Dark- and light-mode images in documenter](https://discourse.julialang.org/t/dark-and-light-mode-images-in-documenter/124214)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 1\
**Last updated:** [December 27, 2024, 6:37pm UTC](https://discourse.julialang.org/t/dark-and-light-mode-images-in-documenter/124214 "2024-12-27T18:37:32Z")

</div>

In github markdown, you can supply two images and include them both in the markdown, appending #gh-dark-mode-only or #gh-light-mode-only to the end of the image url and the appropriate one will display, depending on whet…

---

## [Ccall with a C struct containing a pointer](https://discourse.julialang.org/t/ccall-with-a-c-struct-containing-a-pointer/124036)

<div class="topic-metadata">

**Author:** [@luke-kiernan](https://discourse.julialang.org/u/luke-kiernan)\
**Replies:** 8\
**Last updated:** [December 27, 2024, 3:55pm UTC](https://discourse.julialang.org/t/ccall-with-a-c-struct-containing-a-pointer/124036 "2024-12-27T15:55:02Z")

</div>

I’m writing a Julia interface for a C library. I have a C struct containing C-style array. I’ve wrapped said struct in Julia like so: mutable struct Example data::Ptr{Int64} # in the C, this is an array. end x = Int6…

---

## [Nested C structs, alignment, and "do not copy fields over"](https://discourse.julialang.org/t/nested-c-structs-alignment-and-do-not-copy-fields-over/124191)

<div class="topic-metadata">

**Author:** [@luke-kiernan](https://discourse.julialang.org/u/luke-kiernan)\
**Replies:** 5\
**Last updated:** [December 26, 2024, 11:37pm UTC](https://discourse.julialang.org/t/nested-c-structs-alignment-and-do-not-copy-fields-over/124191 "2024-12-26T23:37:46Z")

</div>

I’m writing a Julia interface for a C library. I have two nested C-style structs, where the inner is used by-value. Thes docs say “declare an isbits struct,” but the inner C struct stores pointers, so that isn’t an optio…

---

## [An easy way to parse escaped newline character?](https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 2\
**Last updated:** [December 26, 2024, 6:09pm UTC](https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188 "2024-12-26T18:09:18Z")

</div>

I have a text file in which I specify some Makie plot labels and some of those labels have newline characters in them. I’ve attempted a few different ways to read that text file so that the two character “\\n” gets transl…

---

## [PythonCall.pyimport opencv on Windows](https://discourse.julialang.org/t/pythoncall-pyimport-opencv-on-windows/124146)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 4\
**Last updated:** [December 26, 2024, 3:42pm UTC](https://discourse.julialang.org/t/pythoncall-pyimport-opencv-on-windows/124146 "2024-12-26T15:42:22Z")

</div>

I’m trying to PythonCall.pyimport opencv on Windows: const cv2 = PythonCall.pynew() function \_\_init\_\_() PythonCall.pycopy!(cv2, pyimport("cv2")) end but I run into Python: ImportError: DLL load failed while import…

---

## [Coloring similar entries in a matrix with the same color](https://discourse.julialang.org/t/coloring-similar-entries-in-a-matrix-with-the-same-color/124160)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 10\
**Last updated:** [December 26, 2024, 2:45pm UTC](https://discourse.julialang.org/t/coloring-similar-entries-in-a-matrix-with-the-same-color/124160 "2024-12-26T14:45:50Z")

</div>

I have a matrix A with many entries but many of them are very close to each other. A small example of A could be: A = \[1.0001 2.0003 1.0; 2.0 3.0001 2.0004; 1.0001 2.0002 1.0\] The actual matrix A is quite…

---

## [Packages for inline tests: Which one I should use?](https://discourse.julialang.org/t/packages-for-inline-tests-which-one-i-should-use/124132)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 6\
**Last updated:** [December 26, 2024, 2:34pm UTC](https://discourse.julialang.org/t/packages-for-inline-tests-which-one-i-should-use/124132 "2024-12-26T14:34:19Z")

</div>

I always like to put short tests along with the code, but the built-in Test does not support this. There are at least two packages: ReTest.jl and TestItems.jl can do this. If I understand correctly, TestItems.jl is devel…

---

## [Removing dependencies from versioned package](https://discourse.julialang.org/t/removing-dependencies-from-versioned-package/124164)

<div class="topic-metadata">

**Author:** [@phma](https://discourse.julialang.org/u/phma)\
**Replies:** 4\
**Last updated:** [December 26, 2024, 12:58pm UTC](https://discourse.julialang.org/t/removing-dependencies-from-versioned-package/124164 "2024-12-26T12:58:46Z")

</div>

I wrote a package WringTwistree, which is a cipher and hash function. When I wrote it, I didn’t know how to use startup.jl, so it depends on Debugger, ProfileView, and Revise, which it doesn’t need but I found useful whe…

---

## [How to generate values after training with Lux.LayerNorm and Lux.BatchNorm](https://discourse.julialang.org/t/how-to-generate-values-after-training-with-lux-layernorm-and-lux-batchnorm/102227)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 5\
**Last updated:** [December 26, 2024, 10:50am UTC](https://discourse.julialang.org/t/how-to-generate-values-after-training-with-lux-layernorm-and-lux-batchnorm/102227 "2024-12-26T10:50:15Z")

</div>

I tried to use Lux.LayerNorm and Dense to train the ODE system on NeuralPDE as follows: domains = \[t ∈ Interval(0.0,25.0)\] chain =\[Lux.Chain(Lux.LayerNorm((1,),Lux.relu),Dense(1,10,Lux.tanh),Dense(10,20,Lux.tanh),Dense…

---

## [Problem installing packages using Julia 1.11.2](https://discourse.julialang.org/t/problem-installing-packages-using-julia-1-11-2/123601)

<div class="topic-metadata">

**Author:** [@Science\_Mohammad](https://discourse.julialang.org/u/Science_Mohammad)\
**Replies:** 19\
**Last updated:** [December 25, 2024, 4:42pm UTC](https://discourse.julialang.org/t/problem-installing-packages-using-julia-1-11-2/123601 "2024-12-25T16:42:25Z")

</div>

I don’t know why 65% of pkgs can not be installed on my computer. Please explain why?. I’m using Julia version 1.11.2, I used julia version 1,10.6 Thank you so much

---

## [Building julia tarball from specific commit](https://discourse.julialang.org/t/building-julia-tarball-from-specific-commit/124154)

<div class="topic-metadata">

**Author:** [@Lior\_Assouline](https://discourse.julialang.org/u/Lior_Assouline)\
**Replies:** 7\
**Last updated:** [December 25, 2024, 7:06am UTC](https://discourse.julialang.org/t/building-julia-tarball-from-specific-commit/124154 "2024-12-25T07:06:27Z")

</div>

Hi All, Is there a documentation regarding the exact script that build the julia tarballs on specific releases? Specifically, I would like to build a tarball which has the same structure as if it was a 1.11.2 release b…

---

## [Pluto.jl - How do I dispatch to a subtype created in a notebook?](https://discourse.julialang.org/t/pluto-jl-how-do-i-dispatch-to-a-subtype-created-in-a-notebook/124162)

<div class="topic-metadata">

**Author:** [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Replies:** 2\
**Last updated:** [December 25, 2024, 1:18am UTC](https://discourse.julialang.org/t/pluto-jl-how-do-i-dispatch-to-a-subtype-created-in-a-notebook/124162 "2024-12-25T01:18:30Z")

</div>

I created a small package called ProblematicAnimals.jl to demonstrate a problem I’m having with Pluto.jl notebooks. I sincerely hope a solution to this can be found. Defined outside of Pluto abstract type AbstractAnima…

---

## [Why doesn't this return statement return?](https://discourse.julialang.org/t/why-doesnt-this-return-statement-return/124142)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 4\
**Last updated:** [December 24, 2024, 3:53pm UTC](https://discourse.julialang.org/t/why-doesnt-this-return-statement-return/124142 "2024-12-24T15:53:55Z")

</div>

When attempting to return out of a function’s loop, the following return statement instead behaves like a break statement: breaking out of the loop but not returning from the function. function mweret() # write temp fi…

---

## [Accelerating calling a Julia function from Python via juliacall and ctypes](https://discourse.julialang.org/t/accelerating-calling-a-julia-function-from-python-via-juliacall-and-ctypes/124143)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 7\
**Last updated:** [December 24, 2024, 2:27pm UTC](https://discourse.julialang.org/t/accelerating-calling-a-julia-function-from-python-via-juliacall-and-ctypes/124143 "2024-12-24T14:27:54Z")

</div>

I was creating an example of using a Julia function from Python via pyjuliacall, but I noticed the overhead was quite high. Below I outline how to reduce the overhead of calling the Julia function from Python by using Ju…

---

## [How to setup a user defined type to work in arithmetical expressions when the type acts as a vector](https://discourse.julialang.org/t/how-to-setup-a-user-defined-type-to-work-in-arithmetical-expressions-when-the-type-acts-as-a-vector/124101)

<div class="topic-metadata">

**Author:** [@David\_Sagan](https://discourse.julialang.org/u/David_Sagan)\
**Replies:** 1\
**Last updated:** [December 24, 2024, 10:33am UTC](https://discourse.julialang.org/t/how-to-setup-a-user-defined-type-to-work-in-arithmetical-expressions-when-the-type-acts-as-a-vector/124101 "2024-12-24T10:33:11Z")

</div>

Setting up a struct to act as a scalar in arithmetical expressions is easy. For example: mutable struct D \<: Number; v; end Base.promote\_rule(::Type{D}, ::Type{T}) where T = T Base.convert(::Type{T}, d::D) where T \<: Nu…

---

## [Why did I get IO error when broadcasting higher precision (bits \>= 98) ArbFloat variables to workers?](https://discourse.julialang.org/t/why-did-i-get-io-error-when-broadcasting-higher-precision-bits-98-arbfloat-variables-to-workers/124025)

<div class="topic-metadata">

**Author:** [@Edsnowden233](https://discourse.julialang.org/u/Edsnowden233)\
**Replies:** 6\
**Last updated:** [December 24, 2024, 7:43am UTC](https://discourse.julialang.org/t/why-did-i-get-io-error-when-broadcasting-higher-precision-bits-98-arbfloat-variables-to-workers/124025 "2024-12-24T07:43:49Z")

</div>

I used the following code to test the data allocation on distributed workers. I found that broadcasting an ArbFloat variable to workers with precision equal to or higher than 98 bits will cause the IO error. Code: usi…

---

## [How to apply fft to an array of static arrays?](https://discourse.julialang.org/t/how-to-apply-fft-to-an-array-of-static-arrays/124127)

<div class="topic-metadata">

**Author:** [@marcsgil](https://discourse.julialang.org/u/marcsgil)\
**Replies:** 4\
**Last updated:** [December 24, 2024, 6:58am UTC](https://discourse.julialang.org/t/how-to-apply-fft-to-an-array-of-static-arrays/124127 "2024-12-24T06:58:54Z")

</div>

I’d like to be able to do something like using StaticArrays, FFTW A = \[@SVector rand(ComplexF64, 3) for m ∈ 1:512\] fft(A) but FFTW.jl throws an error when I try it. Due to performance and ergonomic reasons, I really w…

---

## [Scaling of Bessel Function Y for small x in SpecialFunctions](https://discourse.julialang.org/t/scaling-of-bessel-function-y-for-small-x-in-specialfunctions/124141)

<div class="topic-metadata">

**Author:** [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Replies:** 3\
**Last updated:** [December 24, 2024, 2:30am UTC](https://discourse.julialang.org/t/scaling-of-bessel-function-y-for-small-x-in-specialfunctions/124141 "2024-12-24T02:30:03Z")

</div>

Normally, there is a scaled version of the Bessel functions J\_m(x) and Y\_m(x) for large x. Nevertheless, the Y\_m functions also diverge quickly for x close to zero, and I would like to ask if there is an analogous scaled…

---

## [Curve fitting with NonlinearSolve.jl](https://discourse.julialang.org/t/curve-fitting-with-nonlinearsolve-jl/119238)

<div class="topic-metadata">

**Author:** [@garrek](https://discourse.julialang.org/u/garrek)\
**Replies:** 9\
**Last updated:** [December 24, 2024, 1:34am UTC](https://discourse.julialang.org/t/curve-fitting-with-nonlinearsolve-jl/119238 "2024-12-24T01:34:14Z")

</div>

I am trying to familiarize myself with the NonlinearSolve ecosystem for curve fitting and am having difficulty getting a simple fit to an exponential function. I have seen other discussions on doing this here, but I’m no…

---

## [Looking for Some Best Practices for Optimizing Julia Code Performance?](https://discourse.julialang.org/t/looking-for-some-best-practices-for-optimizing-julia-code-performance/124117)

<div class="topic-metadata">

**Author:** [@danielljose](https://discourse.julialang.org/u/danielljose)\
**Replies:** 5\
**Last updated:** [December 23, 2024, 10:14pm UTC](https://discourse.julialang.org/t/looking-for-some-best-practices-for-optimizing-julia-code-performance/124117 "2024-12-23T22:14:46Z")

</div>

Hi everyone, I am new to Julia and absolutely loving its speed and simplicity so far. However, as I start working on more complex projects…, I would like to ensure my code is as efficient as possible. I have read about …

---

## [Weird behavior of lyapynovspectrum from ChaosTools.jl](https://discourse.julialang.org/t/weird-behavior-of-lyapynovspectrum-from-chaostools-jl/124136)

<div class="topic-metadata">

**Author:** [@EvgenijGr](https://discourse.julialang.org/u/EvgenijGr)\
**Replies:** 3\
**Last updated:** [December 23, 2024, 9:18pm UTC](https://discourse.julialang.org/t/weird-behavior-of-lyapynovspectrum-from-chaostools-jl/124136 "2024-12-23T21:18:12Z")

</div>

Hello! I’ve encountered a weird behavior of lyapunovspectrum when I was investigating my nonlinear system. A MWE can be found here: using ChaosTools, DifferentialEquations, CairoMakie function couple(x, y, vThr, k, hO…

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

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