# General Usage

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

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

**Page:** 162

---

## [How is memory allocated for a vector of structs?](https://discourse.julialang.org/t/how-is-memory-allocated-for-a-vector-of-structs/115314)

<div class="topic-metadata">

**Author:** [@fmario](https://discourse.julialang.org/u/fmario)\
**Replies:** 9\
**Last updated:** [June 7, 2024, 2:31pm UTC](https://discourse.julialang.org/t/how-is-memory-allocated-for-a-vector-of-structs/115314 "2024-06-07T14:31:54Z")

</div>

Say we have a mutable struct like this: mutable struct Foo a::Int b::Int end I have to allocate many of these structs. In C, I would allocate them all at once in an array, instead of using malloc to allocate e…

---

## [Effect of typing in structures](https://discourse.julialang.org/t/effect-of-typing-in-structures/115331)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 4\
**Last updated:** [June 7, 2024, 2:01pm UTC](https://discourse.julialang.org/t/effect-of-typing-in-structures/115331 "2024-06-07T14:01:13Z")

</div>

I have a package which contains a couple of structures that are essential to the package’s functionality. There has been a question of how to handle unknown/parametric types. Basically, to my knowledge, there are three a…

---

## [Is the flag --project expected to activate/instantiate?](https://discourse.julialang.org/t/is-the-flag-project-expected-to-activate-instantiate/115265)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 7\
**Last updated:** [June 7, 2024, 1:44pm UTC](https://discourse.julialang.org/t/is-the-flag-project-expected-to-activate-instantiate/115265 "2024-06-07T13:44:25Z")

</div>

I run julia as julia --project=., and I get So it looks like just using this command line flag did not cause activate/instantiate to run. Is that expected?

---

## [How to make a random selection keeping minimum distance between values](https://discourse.julialang.org/t/how-to-make-a-random-selection-keeping-minimum-distance-between-values/115315)

<div class="topic-metadata">

**Author:** [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Replies:** 3\
**Last updated:** [June 7, 2024, 12:12pm UTC](https://discourse.julialang.org/t/how-to-make-a-random-selection-keeping-minimum-distance-between-values/115315 "2024-06-07T12:12:34Z")

</div>

m = 100 n = 10 b = rand(1:m,n) b = sort(b) I want the minimum distance between adjacent values of b to be \>= 2. How can I do that. I have tried b = rand(1:m,n) while true if lengt…

---

## [Strange performance problem](https://discourse.julialang.org/t/strange-performance-problem/115227)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 14\
**Last updated:** [June 7, 2024, 9:12am UTC](https://discourse.julialang.org/t/strange-performance-problem/115227 "2024-06-07T09:12:00Z")

</div>

Hi all, I am new to this forum. Nice to meet you. Today I encouted a strange performance problem. I benchmarked below codes with Benchmarktools. NG = 2 N = NX = NY = NZ = 256 U = rand!(zeros(N + 2NG, N + 2NG, N + 2NG)…

---

## [Multiple dispatch doesn't find the correct method using \`Type\`](https://discourse.julialang.org/t/multiple-dispatch-doesnt-find-the-correct-method-using-type/115247)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 11\
**Last updated:** [June 7, 2024, 8:38am UTC](https://discourse.julialang.org/t/multiple-dispatch-doesnt-find-the-correct-method-using-type/115247 "2024-06-07T08:38:11Z")

</div>

I am in a confusing situation where I cannot find out why a method is not found. Since it’s hard to explain I will directly post the MWE. using Test abstract type RSAState end abstract type RSAAction end abstract type…

---

## [Do-Block Syntax with Where Keyword](https://discourse.julialang.org/t/do-block-syntax-with-where-keyword/115131)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 16\
**Last updated:** [June 7, 2024, 6:46am UTC](https://discourse.julialang.org/t/do-block-syntax-with-where-keyword/115131 "2024-06-07T06:46:28Z")

</div>

I want to use a finalizer for a parametric type using the type parameter in the finalizer. I have a solution for that, but I wondered whether I can use the do syntax, but I simply do not know where the where needs to be …

---

## [Is there a simple way to differentiate multiple lines with sparse markers?](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307)

<div class="topic-metadata">

**Author:** [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Replies:** 6\
**Last updated:** [June 7, 2024, 6:31am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307 "2024-06-07T06:31:28Z")

</div>

Hi, I have a multiple-line plot like this The figure is ugly owing to the unnecessary markers for each data point. How can I differentiate the two lines with less markers?

---

## [Building Julia for Nix](https://discourse.julialang.org/t/building-julia-for-nix/115304)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 14\
**Last updated:** [June 7, 2024, 5:44am UTC](https://discourse.julialang.org/t/building-julia-for-nix/115304 "2024-06-07T05:44:06Z")

</div>

Nix is this nice tool for reproducible builds on Linux and MacOS that I’ve been trying to learn. Currently the main nixpkgs repository only builds Julia on Linux\[1\] (both x86\_64 and aarch64), so I’m trying to add suppor…

---

## [Zygote.hessian of loss function when defining ODEs with modeling toolkit](https://discourse.julialang.org/t/zygote-hessian-of-loss-function-when-defining-odes-with-modeling-toolkit/115302)

<div class="topic-metadata">

**Author:** [@cefitzg](https://discourse.julialang.org/u/cefitzg)\
**Replies:** 1\
**Last updated:** [June 7, 2024, 2:02am UTC](https://discourse.julialang.org/t/zygote-hessian-of-loss-function-when-defining-odes-with-modeling-toolkit/115302 "2024-06-07T02:02:29Z")

</div>

I’m doing parameter estimation on an ODE system, which I define using modelingtoolkit. I need to generate hessian of cost function with respect to parameters to access fit. No issue with parameter estimation. Loss funct…

---

## [VSCode Debugger not hitting breakpoint in include file](https://discourse.julialang.org/t/vscode-debugger-not-hitting-breakpoint-in-include-file/46014)

<div class="topic-metadata">

**Author:** [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Replies:** 6\
**Last updated:** [June 7, 2024, 1:05am UTC](https://discourse.julialang.org/t/vscode-debugger-not-hitting-breakpoint-in-include-file/46014 "2024-06-07T01:05:15Z")

</div>

If I set a breakpoint in an included file, the breakpoint is not getting hit. Below shows my setup. I simply click the debug button to run test1.jl, the debugger runs and never stops at the break point. Running Julia …

---

## [A good way of running Julia MPI jobs with slurm on HPC platforms](https://discourse.julialang.org/t/a-good-way-of-running-julia-mpi-jobs-with-slurm-on-hpc-platforms/115244)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 7\
**Last updated:** [June 6, 2024, 4:53pm UTC](https://discourse.julialang.org/t/a-good-way-of-running-julia-mpi-jobs-with-slurm-on-hpc-platforms/115244 "2024-06-06T16:53:07Z")

</div>

For some reason the Julia MPI jobs that I submit end in error due to a lack of instantiation / activation. I do run it as mpiexec julia --project=~/a64fx/FinEtoolsDDParallel.jl/examples ~/a64fx/FinEtoolsDDParallel.jl/e…

---

## [Help resolving perturbation confusion in \`ForwardDiff.jl\` with manual higher-order derivatives](https://discourse.julialang.org/t/help-resolving-perturbation-confusion-in-forwarddiff-jl-with-manual-higher-order-derivatives/115297)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 0\
**Last updated:** [June 6, 2024, 8:25pm UTC](https://discourse.julialang.org/t/help-resolving-perturbation-confusion-in-forwarddiff-jl-with-manual-higher-order-derivatives/115297 "2024-06-06T20:25:39Z")

</div>

Hey ForwardDiffers, I’m wondering if I could get some help with resolving a perturbation confusing issue I’m having with some code. I use the follow setup to compute higher-order derivatives with ForwardDiff in a fast a…

---

## [Lock free sorted linked list](https://discourse.julialang.org/t/lock-free-sorted-linked-list/115157)

<div class="topic-metadata">

**Author:** [@melevy](https://discourse.julialang.org/u/melevy)\
**Replies:** 18\
**Last updated:** [June 6, 2024, 7:29pm UTC](https://discourse.julialang.org/t/lock-free-sorted-linked-list/115157 "2024-06-06T19:29:10Z")

</div>

Hi! I’m trying to implement a lock free sorted linked list as shown in 9.8 Nonblocking synchronization of the book titled The art of multiprocessor programming. I need something like AtomicMarkableReference or maybe…

---

## [Trouble with CPU+GPU adjoints for UDEs](https://discourse.julialang.org/t/trouble-with-cpu-gpu-adjoints-for-udes/115290)

<div class="topic-metadata">

**Author:** [@19fitzna](https://discourse.julialang.org/u/19fitzna)\
**Replies:** 1\
**Last updated:** [June 6, 2024, 5:49pm UTC](https://discourse.julialang.org/t/trouble-with-cpu-gpu-adjoints-for-udes/115290 "2024-06-06T17:49:02Z")

</div>

Hi all! I am currently trying to create UDEs using a GPU backend for the neural network only. I have been following the examples here, but have not been able to get anything to work. I was wondering if anyone might know …

---

## [Solving linear system BC = X where B is a symmetric positive semi-definite matrix](https://discourse.julialang.org/t/solving-linear-system-bc-x-where-b-is-a-symmetric-positive-semi-definite-matrix/115280)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 7\
**Last updated:** [June 6, 2024, 4:19pm UTC](https://discourse.julialang.org/t/solving-linear-system-bc-x-where-b-is-a-symmetric-positive-semi-definite-matrix/115280 "2024-06-06T16:19:18Z")

</div>

I am trying to solve for X in BC=X where B is a symmetric positive semi-definite matrix and X is simply a vector with 1 in all of it’s entries. As far as I understand, this can be solved using C=B\\X , but I was wondering…

---

## [Pkg Extension loading errors only on HPC filesystem](https://discourse.julialang.org/t/pkg-extension-loading-errors-only-on-hpc-filesystem/115035)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 3\
**Last updated:** [June 6, 2024, 2:21pm UTC](https://discourse.julialang.org/t/pkg-extension-loading-errors-only-on-hpc-filesystem/115035 "2024-06-06T14:21:40Z")

</div>

Status \`/tmp/jiling/jl\_ZPW1yy/Project.toml\` \[8197267c\] IntervalSets v0.7.10 \[9a3f8284\] Random julia\> using IntervalSets julia\> Base.retry\_load\_extensions() ┌ Error: Error during loading of extension IntervalSetsRan…

---

## [How to import submodules](https://discourse.julialang.org/t/how-to-import-submodules/115277)

<div class="topic-metadata">

**Author:** [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Replies:** 1\
**Last updated:** [June 6, 2024, 2:20pm UTC](https://discourse.julialang.org/t/how-to-import-submodules/115277 "2024-06-06T14:20:08Z")

</div>

So I want to write a package for Querying Astronomy data and I want to make extensive use of submodules to seperate different queryable services. An example is in the following code: module AstronomyQuery module Sim…

---

## [Pkg behaving differently for Package from Registry vs the direct URL](https://discourse.julialang.org/t/pkg-behaving-differently-for-package-from-registry-vs-the-direct-url/115228)

<div class="topic-metadata">

**Author:** [@Simon\_Exner](https://discourse.julialang.org/u/Simon_Exner)\
**Replies:** 2\
**Last updated:** [June 6, 2024, 12:50pm UTC](https://discourse.julialang.org/t/pkg-behaving-differently-for-package-from-registry-vs-the-direct-url/115228 "2024-06-06T12:50:48Z")

</div>

Hello, I have an issue with the behavior of pkg: add FMIZoo results in FMIZoo.jl beeing installed and along with it Interpolations.jl 0.14.0 (which is in FMIZoo.jls dependencys) add "https://github.com/ThummeTo/FMIZoo…

---

## [Maximum of a continous function](https://discourse.julialang.org/t/maximum-of-a-continous-function/115258)

<div class="topic-metadata">

**Author:** [@cmichelenstrofer](https://discourse.julialang.org/u/cmichelenstrofer)\
**Replies:** 2\
**Last updated:** [June 6, 2024, 12:16pm UTC](https://discourse.julialang.org/t/maximum-of-a-continous-function/115258 "2024-06-06T12:16:48Z")

</div>

Packages like Plots and Integrals are able to determine point spacing by themselves (I imagine it is some sort of adaptive algorithm based on how quickly the function is changing). I would imagine that something similar …

---

## [LoadError: Cannot locate artifact 'kaleido' for aarch64-apple-darwin…](https://discourse.julialang.org/t/loaderror-cannot-locate-artifact-kaleido-for-aarch64-apple-darwin/115245)

<div class="topic-metadata">

**Author:** [@artbx25](https://discourse.julialang.org/u/artbx25)\
**Replies:** 1\
**Last updated:** [June 6, 2024, 11:19am UTC](https://discourse.julialang.org/t/loaderror-cannot-locate-artifact-kaleido-for-aarch64-apple-darwin/115245 "2024-06-06T11:19:41Z")

</div>

Hi, I’m new to Julia and trying to run a project on a mac M1 with Julia v1.10 that needs the packages: ✗ PlotlyBase ✗ ORCA ✗ PlotlyJS However when trying to add them I get an error (they also can’t be precompiled). …

---

## [Intersection of level sets](https://discourse.julialang.org/t/intersection-of-level-sets/114913)

<div class="topic-metadata">

**Author:** [@cmarcotte](https://discourse.julialang.org/u/cmarcotte)\
**Replies:** 12\
**Last updated:** [June 6, 2024, 9:26am UTC](https://discourse.julialang.org/t/intersection-of-level-sets/114913 "2024-06-06T09:26:57Z")

</div>

Hello! I am computing the intersections of two level sets computed from some input arrays. The idea is that, having retrieved the contours from Makie we can compute the intersections of the curves by iterating over sequ…

---

## [Why is dispatching on \`Val\` freezing Julia?](https://discourse.julialang.org/t/why-is-dispatching-on-val-freezing-julia/115267)

<div class="topic-metadata">

**Author:** [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Replies:** 2\
**Last updated:** [June 6, 2024, 5:26am UTC](https://discourse.julialang.org/t/why-is-dispatching-on-val-freezing-julia/115267 "2024-06-06T05:26:19Z")

</div>

I expected a MethodError but this freezes Julia. f(::Val{0}) = nothing; f(x) = f(Val(x)); f(1) julia\> versioninfo() Julia Version 1.10.3 Commit 0b4590a5507 (2024-04-30 10:59 UTC) Build Info: Official https://julialan…

---

## [Problem Turing bug multivariate Bernoulli](https://discourse.julialang.org/t/problem-turing-bug-multivariate-bernoulli/115183)

<div class="topic-metadata">

**Author:** [@Marta\_Pardo\_Araujo](https://discourse.julialang.org/u/Marta_Pardo_Araujo)\
**Replies:** 3\
**Last updated:** [June 5, 2024, 11:27pm UTC](https://discourse.julialang.org/t/problem-turing-bug-multivariate-bernoulli/115183 "2024-06-05T23:27:58Z")

</div>

I am trying to estimate the paremeters of a model using Turing, in the code below there is a toy model for simplicity. This model as output has a 10 dimensional reponse variable. Therefore for each time I have a vector a…

---

## [Get value in nested data structure of arbitrary depth](https://discourse.julialang.org/t/get-value-in-nested-data-structure-of-arbitrary-depth/115254)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 5\
**Last updated:** [June 5, 2024, 10:19pm UTC](https://discourse.julialang.org/t/get-value-in-nested-data-structure-of-arbitrary-depth/115254 "2024-06-05T22:19:56Z")

</div>

Hi, I would like to acess values of nested data structure with a Tuple representing the fields location in the data structure. The data structure can be of an arbitrary type and depth. Here is a MWE illustrating a few o…

---

## [Storage format for lots of strings](https://discourse.julialang.org/t/storage-format-for-lots-of-strings/115256)

<div class="topic-metadata">

**Author:** [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Replies:** 7\
**Last updated:** [June 5, 2024, 9:50pm UTC](https://discourse.julialang.org/t/storage-format-for-lots-of-strings/115256 "2024-06-05T21:50:54Z")

</div>

Sorry to hijack this thread but I have another problem also with scale and was wondering if anyone has dealt with this scale before. I basically have 180 billion strings, SMILES, that I would like to store and work with …

---

## [When to use \`using Package: function\` and when to use \`import Package: function\`](https://discourse.julialang.org/t/when-to-use-using-package-function-and-when-to-use-import-package-function/115091)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 20\
**Last updated:** [June 5, 2024, 8:43pm UTC](https://discourse.julialang.org/t/when-to-use-using-package-function-and-when-to-use-import-package-function/115091 "2024-06-05T20:43:54Z")

</div>

I have a package, which imports a couple of package, as well as a couple of extra functions from these. I am trying to figure out whether there is some “rule” for whether to use using Package: function or import Packa…

---

## [Fails test at calling \`Docs.undocumented\_names\` in Julia stdlib](https://discourse.julialang.org/t/fails-test-at-calling-docs-undocumented-names-in-julia-stdlib/115224)

<div class="topic-metadata">

**Author:** [@paalon](https://discourse.julialang.org/u/paalon)\
**Replies:** 1\
**Last updated:** [June 5, 2024, 4:58pm UTC](https://discourse.julialang.org/t/fails-test-at-calling-docs-undocumented-names-in-julia-stdlib/115224 "2024-06-05T16:58:04Z")

</div>

I’m editing Julia’s standard library and fail test at the following: @testset "Docstrings" begin @test isempty(Docs.undocumented\_names(Unicode)) end Docstrings: Error During Test at /Users/paalon/git/julia/stdlib/U…

---

## [Preallocating and returning anonymous function](https://discourse.julialang.org/t/preallocating-and-returning-anonymous-function/115241)

<div class="topic-metadata">

**Author:** [@kockahonza](https://discourse.julialang.org/u/kockahonza)\
**Replies:** 4\
**Last updated:** [June 5, 2024, 4:27pm UTC](https://discourse.julialang.org/t/preallocating-and-returning-anonymous-function/115241 "2024-06-05T16:27:51Z")

</div>

Hi, so I’m working on a project and I want to avoid many allocations called in a loop as is often suggested. That said I also want to avoid having to pass all the preallocated arrays/space/whatever it is at every functio…

---

## [Type instability of discrete mixture distribution](https://discourse.julialang.org/t/type-instability-of-discrete-mixture-distribution/115118)

<div class="topic-metadata">

**Author:** [@mlanghinrichs](https://discourse.julialang.org/u/mlanghinrichs)\
**Replies:** 15\
**Last updated:** [June 5, 2024, 1:22pm UTC](https://discourse.julialang.org/t/type-instability-of-discrete-mixture-distribution/115118 "2024-06-05T13:22:49Z")

</div>

Hi all, I want to define a custom distribution that is a modification of the Geometric distribution (the one that has support {1,2,3,...}) with an additional “atom” at the event 0. I.e. this is a well-defined distributi…

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

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