# General Usage

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

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

**Page:** 213

---

## [Struct and memory allocation](https://discourse.julialang.org/t/struct-and-memory-allocation/108632)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 4\
**Last updated:** [January 10, 2024, 4:29pm UTC](https://discourse.julialang.org/t/struct-and-memory-allocation/108632 "2024-01-10T16:29:07Z")

</div>

Hello ! :slight\_smile: I don’t understand why there is memory allocation when I acces to a parameters of my immutable struct ? julia\> using BenchmarkTools julia\> struct S1 a::NTuple{3,Int64} b::Float64 …

---

## [NeuralODE - Array has no field layer](https://discourse.julialang.org/t/neuralode-array-has-no-field-layer/108586)

<div class="topic-metadata">

**Author:** [@Nocix](https://discourse.julialang.org/u/Nocix)\
**Replies:** 6\
**Last updated:** [January 10, 2024, 2:46pm UTC](https://discourse.julialang.org/t/neuralode-array-has-no-field-layer/108586 "2024-01-10T14:46:11Z")

</div>

Hi, I’m new here and have a question about extrapolating data using neural ordinary differential equations. I am in the process of training a mathematical function in steps of four. Training the neural network seems to …

---

## [Collect (flat) iterator as an Array](https://discourse.julialang.org/t/collect-flat-iterator-as-an-array/108617)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [January 10, 2024, 12:52pm UTC](https://discourse.julialang.org/t/collect-flat-iterator-as-an-array/108617 "2024-01-10T12:52:54Z")

</div>

Is there a default generic way I can collect an iterator itr that HasLength into an Array of given (compatible) dims? Eg collect itr = (i for i in 1:6) into a 2x3 Matrix. Just to clarify, it is easy to write a wrappe…

---

## [How to return self recursive function?](https://discourse.julialang.org/t/how-to-return-self-recursive-function/108564)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 8\
**Last updated:** [January 10, 2024, 11:57am UTC](https://discourse.julialang.org/t/how-to-return-self-recursive-function/108564 "2024-01-10T11:57:17Z")

</div>

I want to make a function that takes a function and vector of initial conditions as arguments. function recseq( a::T, init::AbstractVector) where{T\<:Function} return n-\> begin if(n in init) return init\[n+1\] e…

---

## [Julia and Pkg are the best](https://discourse.julialang.org/t/julia-and-pkg-are-the-best/108610)

<div class="topic-metadata">

**Author:** [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Replies:** 2\
**Last updated:** [January 10, 2024, 11:24am UTC](https://discourse.julialang.org/t/julia-and-pkg-are-the-best/108610 "2024-01-10T11:24:50Z")

</div>

I have a pipeline that has Julia, R and python and bash-run docker clis and everything is fragile and breaking across builds. But! when the julia package chokes on unexpected input, I dev the package, and revise (on by …

---

## [Makie.jl: How to color a density plot according to a given colormap/colorbar](https://discourse.julialang.org/t/makie-jl-how-to-color-a-density-plot-according-to-a-given-colormap-colorbar/60575)

<div class="topic-metadata">

**Author:** [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Replies:** 1\
**Last updated:** [January 10, 2024, 9:47am UTC](https://discourse.julialang.org/t/makie-jl-how-to-color-a-density-plot-according-to-a-given-colormap-colorbar/60575 "2024-01-10T09:47:13Z")

</div>

Is it possible to color densities according to a given colormap/colorbar? @yakir12 already helped me on zulip with the “ridgeplot layout” of the densities as shown in the docs, which worked for me like below: But I’…

---

## [Plots; pythonplot(): approximate heatmap as gradients to save space](https://discourse.julialang.org/t/plots-pythonplot-approximate-heatmap-as-gradients-to-save-space/108293)

<div class="topic-metadata">

**Author:** [@maltee1](https://discourse.julialang.org/u/maltee1)\
**Replies:** 8\
**Last updated:** [January 10, 2024, 8:02am UTC](https://discourse.julialang.org/t/plots-pythonplot-approximate-heatmap-as-gradients-to-save-space/108293 "2024-01-10T08:02:44Z")

</div>

Hi, Is it possible to turn a heatmap from individual pixels into something that’s a little easier on storage? Especially, if nothing very exciting is happening in most places of the heatmap, a collection of gradients co…

---

## [Check if function accepts specific keyword argument](https://discourse.julialang.org/t/check-if-function-accepts-specific-keyword-argument/108605)

<div class="topic-metadata">

**Author:** [@sandyspiers](https://discourse.julialang.org/u/sandyspiers)\
**Replies:** 3\
**Last updated:** [January 10, 2024, 7:06am UTC](https://discourse.julialang.org/t/check-if-function-accepts-specific-keyword-argument/108605 "2024-01-10T07:06:15Z")

</div>

Suppose I have julia\> f(;y=1) = y f (generic function with 1 method) If I want to check whether f accepts y as a keyword argument I can do julia\> hasmethod(f, Tuple{}, (:y,)) true But this requires knowing the number…

---

## [Odd behavior with mul!() and @view](https://discourse.julialang.org/t/odd-behavior-with-mul-and-view/108606)

<div class="topic-metadata">

**Author:** [@johnb](https://discourse.julialang.org/u/johnb)\
**Replies:** 3\
**Last updated:** [January 10, 2024, 5:44am UTC](https://discourse.julialang.org/t/odd-behavior-with-mul-and-view/108606 "2024-01-10T05:44:21Z")

</div>

I’m trying to use mul!() to perform low-memory multiplications on subsets of larger matrices using code. My actual code loops through many slices of smaller views of a large matrix (large set of ODEs chunked for easier u…

---

## [Dictionaries for StaticCompiler?](https://discourse.julialang.org/t/dictionaries-for-staticcompiler/108601)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 1\
**Last updated:** [January 10, 2024, 3:50am UTC](https://discourse.julialang.org/t/dictionaries-for-staticcompiler/108601 "2024-01-10T03:50:35Z")

</div>

Is there any dictionary implementation that does not need GC and is therefore compatible with StaticCompiler.jl for the purpose of compiling small binary executables?

---

## [Mutlithread functions within for loop](https://discourse.julialang.org/t/mutlithread-functions-within-for-loop/108577)

<div class="topic-metadata">

**Author:** [@trasor](https://discourse.julialang.org/u/trasor)\
**Replies:** 3\
**Last updated:** [January 9, 2024, 8:58pm UTC](https://discourse.julialang.org/t/mutlithread-functions-within-for-loop/108577 "2024-01-09T20:58:29Z")

</div>

Hello everyone, im kinda new to julia (self learning since a few weeks). I am wondering how to use multithreading properly for functions within a for loop like: A = … (some 3d array) B = …(some 3d array) for i in 1:1…

---

## [CI on Linux: which system fonts are available?](https://discourse.julialang.org/t/ci-on-linux-which-system-fonts-are-available/108588)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 2\
**Last updated:** [January 9, 2024, 8:40pm UTC](https://discourse.julialang.org/t/ci-on-linux-which-system-fonts-are-available/108588 "2024-01-09T20:40:55Z")

</div>

Documentation for a package is built on Linux CI. Does anybody know what system fonts are available to Julia when the docs are being built? I want to specify some different fonts for some examples but don’t know which on…

---

## [How to pass Ref of struct containing Cstring to Fortran](https://discourse.julialang.org/t/how-to-pass-ref-of-struct-containing-cstring-to-fortran/107878)

<div class="topic-metadata">

**Author:** [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Replies:** 3\
**Last updated:** [January 9, 2024, 8:04pm UTC](https://discourse.julialang.org/t/how-to-pass-ref-of-struct-containing-cstring-to-fortran/107878 "2024-01-09T20:04:05Z")

</div>

I have a struct that contains a Cstring. I saw this older post about how to pass such a struct to C: I need to pass such a struct to Fortran (the Fortran code converts the C-style string to a Fortran string), so that …

---

## [Failure to optimize due to type recursion](https://discourse.julialang.org/t/failure-to-optimize-due-to-type-recursion/108568)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [January 9, 2024, 4:56pm UTC](https://discourse.julialang.org/t/failure-to-optimize-due-to-type-recursion/108568 "2024-01-09T16:56:31Z")

</div>

I find that it is relatively easy to get non-inferred code where the mapfoldl family is involved, because their implementation has so many layers. Eg a simple example is \_length(c::Real) = 1 \_length(c::Tuple) = mapfoldl…

---

## [PrecompileTools.@compile\_workload does not seem to work at all - what am I doing wrong?](https://discourse.julialang.org/t/precompiletools-compile-workload-does-not-seem-to-work-at-all-what-am-i-doing-wrong/108481)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 4\
**Last updated:** [January 9, 2024, 3:24pm UTC](https://discourse.julialang.org/t/precompiletools-compile-workload-does-not-seem-to-work-at-all-what-am-i-doing-wrong/108481 "2024-01-09T15:24:38Z")

</div>

Hi there, I am testing PrecompileTools, and I just don’t get it to work - despite precompilation seems to work (check by MethodAnalysis.methodinstances), julia just recompiles again and again und process restart… module…

---

## [Build DiffEq functions from Expr](https://discourse.julialang.org/t/build-diffeq-functions-from-expr/17469)

<div class="topic-metadata">

**Author:** [@ivborissov](https://discourse.julialang.org/u/ivborissov)\
**Replies:** 11\
**Last updated:** [January 9, 2024, 3:19pm UTC](https://discourse.julialang.org/t/build-diffeq-functions-from-expr/17469 "2024-01-09T15:19:14Z")

</div>

Hello, my question is both related to building functions from expressions and DiffEq domain. I am working on a simulation engine based on ODE solver and the input problems for the solver are provided as JSON files, whic…

---

## [Fix git artifact on NixOS](https://discourse.julialang.org/t/fix-git-artifact-on-nixos/108567)

<div class="topic-metadata">

**Author:** [@laikq](https://discourse.julialang.org/u/laikq)\
**Replies:** 1\
**Last updated:** [January 9, 2024, 3:09pm UTC](https://discourse.julialang.org/t/fix-git-artifact-on-nixos/108567 "2024-01-09T15:09:48Z")

</div>

I’m using Documenter on NixOS. When I run julia --project make.jl, I get the following error: ┌ Warning: Unable to determine HTML(edit\_link = ...) from remote HEAD branch, defaulting to "master". │ Calling \`git remote\` …

---

## [Implement the "SHA512withRSA" algorithm using OpenSSL](https://discourse.julialang.org/t/implement-the-sha512withrsa-algorithm-using-openssl/108566)

<div class="topic-metadata">

**Author:** [@yshadrin](https://discourse.julialang.org/u/yshadrin)\
**Replies:** 0\
**Last updated:** [January 9, 2024, 2:42pm UTC](https://discourse.julialang.org/t/implement-the-sha512withrsa-algorithm-using-openssl/108566 "2024-01-09T14:42:49Z")

</div>

I have a bash script that allows you to encrypt data using a secret key and the “SHA512withRSA” algorithm: secret="LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2d0lCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktrd2dnU2xBZ0VBQW9JQkFR…

---

## [Adding agents in mixed agent model with continuous space (Agents.jl)](https://discourse.julialang.org/t/adding-agents-in-mixed-agent-model-with-continuous-space-agents-jl/108560)

<div class="topic-metadata">

**Author:** [@eleonoragatti44](https://discourse.julialang.org/u/eleonoragatti44)\
**Replies:** 6\
**Last updated:** [January 9, 2024, 1:52pm UTC](https://discourse.julialang.org/t/adding-agents-in-mixed-agent-model-with-continuous-space-agents-jl/108560 "2024-01-09T13:52:10Z")

</div>

Hi all, I am trying to create an ABM with mixed agents on a continuous space. I tried to do the same on a grid space and everything worked well but when moving to a continuous space I face some issues I didn’t find the w…

---

## [StaticArrays forces recompilation of JLLs on Windows with Julia 1.8.1](https://discourse.julialang.org/t/staticarrays-forces-recompilation-of-jlls-on-windows-with-julia-1-8-1/87725)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 18\
**Last updated:** [January 9, 2024, 12:59pm UTC](https://discourse.julialang.org/t/staticarrays-forces-recompilation-of-jlls-on-windows-with-julia-1-8-1/87725 "2024-01-09T12:59:40Z")

</div>

Eric Davies, @longemen3000, I and others encountered an unexpected result after looking at @time\_imports and discussed it on Slack. Something was forcing JLL packages to recompile a lot of code. We narrowed it down to th…

---

## [Compact string representation of a float](https://discourse.julialang.org/t/compact-string-representation-of-a-float/108526)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 2\
**Last updated:** [January 8, 2024, 6:35pm UTC](https://discourse.julialang.org/t/compact-string-representation-of-a-float/108526 "2024-01-08T18:35:19Z")

</div>

I want the compact (in the sense of IOContext(io, :compact =\> true)) string representation of a floating point number or vector for inclusion in a Quarto document. Currently I define a function function compact(x; buf:…

---

## [How to optimize struct for speed?](https://discourse.julialang.org/t/how-to-optimize-struct-for-speed/108518)

<div class="topic-metadata">

**Author:** [@Alseidon](https://discourse.julialang.org/u/Alseidon)\
**Replies:** 4\
**Last updated:** [January 9, 2024, 8:53am UTC](https://discourse.julialang.org/t/how-to-optimize-struct-for-speed/108518 "2024-01-09T08:53:05Z")

</div>

I am defining a new struct for a project, which I need to be fast. This struct only contains one parameter, an MVector (from the StaticArrays.jl package). However, the operations on the struct are 4x slower than those on…

---

## [How use the dependent lags part in solving ddes](https://discourse.julialang.org/t/how-use-the-dependent-lags-part-in-solving-ddes/108246)

<div class="topic-metadata">

**Author:** [@Ananya\_Hazarika](https://discourse.julialang.org/u/Ananya_Hazarika)\
**Replies:** 7\
**Last updated:** [January 9, 2024, 5:39am UTC](https://discourse.julialang.org/t/how-use-the-dependent-lags-part-in-solving-ddes/108246 "2024-01-09T05:39:19Z")

</div>

prob = DDEProblem(bc\_model, u0, h, tspan; dependent\_lags = ((u, p, t) → tau,)) alg = MethodOfSteps(Tsit5()) sol = solve(prob, alg) if i have lags that are random :within some range i.e ,i want to use random lags for e…

---

## [Error precompiling on cluster](https://discourse.julialang.org/t/error-precompiling-on-cluster/104974)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 26\
**Last updated:** [January 9, 2024, 2:14am UTC](https://discourse.julialang.org/t/error-precompiling-on-cluster/104974 "2024-01-09T02:14:09Z")

</div>

I am running a simple script on a cluster. I simply perform many instances of the same script. I get the following error: \<E2\>\<94\>\<8C\> Warning: The call to compilecache failed to create a usable precompiled cache file …

---

## [More, less, head, tail, to display arrays in REPL](https://discourse.julialang.org/t/more-less-head-tail-to-display-arrays-in-repl/47435)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 23\
**Last updated:** [January 8, 2024, 11:54pm UTC](https://discourse.julialang.org/t/more-less-head-tail-to-display-arrays-in-repl/47435 "2024-01-08T23:54:04Z")

</div>

Is there any functionality which mimics the head, tail, more and less command in bash, but to visualize the contents of arrays? That would be quite useful, I think, for rapid inspection of data. Currently, the Base.disp…

---

## [\`Pkg\` workflow after Julia version update](https://discourse.julialang.org/t/pkg-workflow-after-julia-version-update/108534)

<div class="topic-metadata">

**Author:** [@joaovgranja](https://discourse.julialang.org/u/joaovgranja)\
**Replies:** 6\
**Last updated:** [January 8, 2024, 9:20pm UTC](https://discourse.julialang.org/t/pkg-workflow-after-julia-version-update/108534 "2024-01-08T21:20:50Z")

</div>

I am on Ubuntu 22.04.03. I have installed Julia 1.10 using the curl command here. I want to update a project environment so that it uses Julia 1.10. However, upon activate . and instantiate, several packages fail to prec…

---

## [Memory Increase with DistributedArrays in Loop](https://discourse.julialang.org/t/memory-increase-with-distributedarrays-in-loop/108411)

<div class="topic-metadata">

**Author:** [@jcsyme](https://discourse.julialang.org/u/jcsyme)\
**Replies:** 2\
**Last updated:** [January 8, 2024, 7:08pm UTC](https://discourse.julialang.org/t/memory-increase-with-distributedarrays-in-loop/108411 "2024-01-08T19:08:23Z")

</div>

I’m working on parallelizing some graph algorithms, and I’m trying to use the DistributedArrays package to create an array that allows a worker to operate on a single vector without having to re-generate the array within…

---

## [What does @inline mean?](https://discourse.julialang.org/t/what-does-inline-mean/108516)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 4\
**Last updated:** [January 8, 2024, 4:27pm UTC](https://discourse.julialang.org/t/what-does-inline-mean/108516 "2024-01-08T16:27:09Z")

</div>

I see a lot of “@inline function” in a package. What does it mean? According to https://subscription.packtpub.com/book/programming/9781785880919/4/ch04lvl1sec23/inlining, it is just a way to avoid the function call overh…

---

## [Normalization of eigenvectors in Arpack](https://discourse.julialang.org/t/normalization-of-eigenvectors-in-arpack/108492)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 3\
**Last updated:** [January 8, 2024, 4:22pm UTC](https://discourse.julialang.org/t/normalization-of-eigenvectors-in-arpack/108492 "2024-01-08T16:22:09Z")

</div>

I call eigs from two separate packages. In the first, eigs returns vectors normalized to unit length, in the second they are normalized relative to the second matrix in the pencil (mass). Obviously, both matrix pencils …

---

## [Tuple of Tuple to Tuple](https://discourse.julialang.org/t/tuple-of-tuple-to-tuple/108447)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 9\
**Last updated:** [January 8, 2024, 4:18pm UTC](https://discourse.julialang.org/t/tuple-of-tuple-to-tuple/108447 "2024-01-08T16:18:58Z")

</div>

Hello, I have 2 variables like julia\> a = 1:5 1:5 julia\> b = \[("a", 10), ("b", 20), ("c", 30), ("d", 40) , ("e", 50)\] 5-element Vector{Tuple{String, Int64}}: ("a", 10) ("b", 20) ("c", 30) ("d", 40) ("e", 50) Whe…

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

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