# General Usage

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

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

**Page:** 92

---

## [How to get reference to the field of mutable struct](https://discourse.julialang.org/t/how-to-get-reference-to-the-field-of-mutable-struct/125222)

<div class="topic-metadata">

**Author:** [@Pedro](https://discourse.julialang.org/u/Pedro)\
**Replies:** 5\
**Last updated:** [January 27, 2025, 7:27pm UTC](https://discourse.julialang.org/t/how-to-get-reference-to-the-field-of-mutable-struct/125222 "2025-01-27T19:27:27Z")

</div>

How one can create the reference to the field of the instantiated mutable struct? Let’s say I have a mutable struct A defined as mutable struct A v1::Int v2::Float64 end and an instance of this structure a = A…

---

## [Failing to pre-compile OrdinaryDiffEqDefault](https://discourse.julialang.org/t/failing-to-pre-compile-ordinarydiffeqdefault/125179)

<div class="topic-metadata">

**Author:** [@lpz18](https://discourse.julialang.org/u/lpz18)\
**Replies:** 3\
**Last updated:** [January 27, 2025, 7:18pm UTC](https://discourse.julialang.org/t/failing-to-pre-compile-ordinarydiffeqdefault/125179 "2025-01-27T19:18:56Z")

</div>

Essence of the problem: Can’t install OrdinaryDiffEq anymore More context: I was working in Pluto notebooks and for some reason I can no longer install DifferentialEquations. I isolated it to OrdinaryDiffEqDefault. I …

---

## [ODE non autonomous interpolation needed](https://discourse.julialang.org/t/ode-non-autonomous-interpolation-needed/125175)

<div class="topic-metadata">

**Author:** [@Marta\_Pardo\_Araujo](https://discourse.julialang.org/u/Marta_Pardo_Araujo)\
**Replies:** 15\
**Last updated:** [January 27, 2025, 6:36pm UTC](https://discourse.julialang.org/t/ode-non-autonomous-interpolation-needed/125175 "2025-01-27T18:36:49Z")

</div>

I am trying to optimize my code where I integrate a system of non-autonomous ODEs. The problem is the interpolations that I am doing in order to have the value of a parameter at each time step needed by the integrator. …

---

## [About Finitely presented groups in Oscar.jl](https://discourse.julialang.org/t/about-finitely-presented-groups-in-oscar-jl/125268)

<div class="topic-metadata">

**Author:** [@Hakan\_Kucuk](https://discourse.julialang.org/u/Hakan_Kucuk)\
**Replies:** 4\
**Last updated:** [January 27, 2025, 4:06pm UTC](https://discourse.julialang.org/t/about-finitely-presented-groups-in-oscar-jl/125268 "2025-01-27T16:06:50Z")

</div>

Hello Julia community, I am new to programming, especially abstract programming. I find the Oscar.jl package quite powerful and successful, but I need your help in creating finite and abstract groups ( Finitely presented…

---

## [Package for Non-Parametric Multivariate Discrete Distributions](https://discourse.julialang.org/t/package-for-non-parametric-multivariate-discrete-distributions/125046)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 3\
**Last updated:** [January 27, 2025, 6:48am UTC](https://discourse.julialang.org/t/package-for-non-parametric-multivariate-discrete-distributions/125046 "2025-01-27T06:48:29Z")

</div>

I’m looking for a package that implements tools for working with non-parametric multivariate discrete distributions. Ideally, this would look something like a Multivariate version of DiscreteNonParametric in Distribution…

---

## [Suggestion for how to organize code that requires many parameters](https://discourse.julialang.org/t/suggestion-for-how-to-organize-code-that-requires-many-parameters/125230)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 12\
**Last updated:** [January 26, 2025, 9:19pm UTC](https://discourse.julialang.org/t/suggestion-for-how-to-organize-code-that-requires-many-parameters/125230 "2025-01-26T21:19:29Z")

</div>

I have a “model” that require many parameters and I am struggling to keep a reference to all the paramters in the various subcalls. I would like instead to define a julia file to host the “default” parameters, itself a p…

---

## [Understanding \`Base.findall\` and customizing it](https://discourse.julialang.org/t/understanding-base-findall-and-customizing-it/125220)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 2\
**Last updated:** [January 26, 2025, 1:24pm UTC](https://discourse.julialang.org/t/understanding-base-findall-and-customizing-it/125220 "2025-01-26T13:24:58Z")

</div>

Given a vector ww, I wish to obtain all its nonzero values and the corresponding positions (with specified type). I solve this with: using BenchmarkTools, Test function \_find0(::tp, ww::AbstractVector{tw}) ::Tuple{Vecto…

---

## [How to initialize a \`Dict\` with \`#undef\` content?](https://discourse.julialang.org/t/how-to-initialize-a-dict-with-undef-content/125154)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 6\
**Last updated:** [January 26, 2025, 1:10pm UTC](https://discourse.julialang.org/t/how-to-initialize-a-dict-with-undef-content/125154 "2025-01-26T13:10:28Z")

</div>

I want to initialize a Dict comprised of some #undef values. How can I do this? I tried Dict{String, Float64}(undef, 3) but it throws the following error: ERROR: MethodError: no method matching Dict{String, Float64}(::…

---

## [Parametric types & instances](https://discourse.julialang.org/t/parametric-types-instances/125213)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 5\
**Last updated:** [January 26, 2025, 7:41am UTC](https://discourse.julialang.org/t/parametric-types-instances/125213 "2025-01-26T07:41:47Z")

</div>

I have ~20 trade types. Each has a rate-set struct and a rate-set-instance struct. I’d like to define the rate-sets and rate-set-instances jointly (botom example). There are ~3 rate-set field types and each has a uniqu…

---

## [AD vs argument lists](https://discourse.julialang.org/t/ad-vs-argument-lists/125207)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 5\
**Last updated:** [January 26, 2025, 12:27am UTC](https://discourse.julialang.org/t/ad-vs-argument-lists/125207 "2025-01-26T00:27:06Z")

</div>

To enable AD I must do something about argument types. Let us say I have a function like this: add\_btdb\_ut\_only!(Ke::Matrix{T}, B::Matrix{T}, Jac\_w::T, D::Matrix{T}, DB::Matrix{T}) where {T} I might be able to guess wh…

---

## [GridapGmsh on gmsh.jl object](https://discourse.julialang.org/t/gridapgmsh-on-gmsh-jl-object/82681)

<div class="topic-metadata">

**Author:** [@chupin](https://discourse.julialang.org/u/chupin)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 9:17pm UTC](https://discourse.julialang.org/t/gridapgmsh-on-gmsh-jl-object/82681 "2025-01-25T21:17:53Z")

</div>

I would like to generate a mesh from a set of points defining a contour computed by a Julia program and then to solve a PDE on the generated mesh. I found the package Gmsh.jl to use gmsh program to build a msh file. Th…

---

## [Is \`LsqFit.jl\` abandoned?](https://discourse.julialang.org/t/is-lsqfit-jl-abandoned/125192)

<div class="topic-metadata">

**Author:** [@cocoa1231](https://discourse.julialang.org/u/cocoa1231)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 6:03pm UTC](https://discourse.julialang.org/t/is-lsqfit-jl-abandoned/125192 "2025-01-25T18:03:28Z")

</div>

As the title says, is the package abandoned? There’s PRs that go back to 2020. Is LsqFit.jl no longer maintained? If so what’s the preferred way to do curve fitting similar to scipy.optimize.curve\_fit?

---

## [Too many allocations in functions call](https://discourse.julialang.org/t/too-many-allocations-in-functions-call/125181)

<div class="topic-metadata">

**Author:** [@Miroboru](https://discourse.julialang.org/u/Miroboru)\
**Replies:** 6\
**Last updated:** [January 25, 2025, 3:45pm UTC](https://discourse.julialang.org/t/too-many-allocations-in-functions-call/125181 "2025-01-25T15:45:07Z")

</div>

Consider the following function function foo(n) bar = ones(n) return 0.0 end When running this function (twice) under the @allocations or @time macro, there will be one allocation, which is to be expected: @ti…

---

## [Economy-sized eigendecomposition?](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 4\
**Last updated:** [January 25, 2025, 3:29pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037 "2025-01-25T15:29:55Z")

</div>

Perhaps I’ve missed it, but is there a way to obtain the “economy” eigendecomposition of a matrix whose rank is less than the dimension? That is, if A is size n and rank r \< n, I would like to store just r eigenvalues a…

---

## [Progressive colormap transparency](https://discourse.julialang.org/t/progressive-colormap-transparency/125194)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 3:25pm UTC](https://discourse.julialang.org/t/progressive-colormap-transparency/125194 "2025-01-25T15:25:10Z")

</div>

I was wondering: what is the best way to make a colormap progressively transparent? In practice I’d like to use a colormap (e.g. :bilbao) but I’d like the color to progressively become transparent for low values of the …

---

## [Dict with integer keys and fastest insertion?](https://discourse.julialang.org/t/dict-with-integer-keys-and-fastest-insertion/125171)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 8\
**Last updated:** [January 25, 2025, 1:28pm UTC](https://discourse.julialang.org/t/dict-with-integer-keys-and-fastest-insertion/125171 "2025-01-25T13:28:35Z")

</div>

What are the best options for a dict/map with integer keys and the fastest insert/update? For background, I wish to aggregate those position-weight pairs (p,w) where the position is the same, I’m tinkering with the idea …

---

## [Designing a borrow checker for Julia](https://discourse.julialang.org/t/designing-a-borrow-checker-for-julia/124906)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 8\
**Last updated:** [January 25, 2025, 9:02am UTC](https://discourse.julialang.org/t/designing-a-borrow-checker-for-julia/124906 "2025-01-25T09:02:52Z")

</div>

Hi everyone! I’m working on BorrowChecker.jl, a package that brings a layer of Rust-like ownership and borrowing semantics to Julia to improve memory safety of user code. Before making an official announcement or releasi…

---

## [Naming convention for functions when an argument is optionally mutated](https://discourse.julialang.org/t/naming-convention-for-functions-when-an-argument-is-optionally-mutated/125180)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 5\
**Last updated:** [January 25, 2025, 4:20am UTC](https://discourse.julialang.org/t/naming-convention-for-functions-when-an-argument-is-optionally-mutated/125180 "2025-01-25T04:20:35Z")

</div>

I have a function f with a signature: f(x, y, cache::Union{T1, T2}) where cache will be mutated (modified) when it’s of type T1 and not mutated when it’s of type T2. The type of cache is determined by the combinations …

---

## [Custom array type that defaults to views when sliced?](https://discourse.julialang.org/t/custom-array-type-that-defaults-to-views-when-sliced/125158)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 6\
**Last updated:** [January 24, 2025, 7:31pm UTC](https://discourse.julialang.org/t/custom-array-type-that-defaults-to-views-when-sliced/125158 "2025-01-24T19:31:38Z")

</div>

I’m thinking about making a custom array type that defaults to creating a view when sliced. Is this a bad idea? Would it break things (if so, what things)? For clarity, this question is definitely not to resurrect the d…

---

## [O.O.P in Julia](https://discourse.julialang.org/t/o-o-p-in-julia/124957)

<div class="topic-metadata">

**Author:** [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Replies:** 25\
**Last updated:** [January 24, 2025, 4:26pm UTC](https://discourse.julialang.org/t/o-o-p-in-julia/124957 "2025-01-24T16:26:53Z")

</div>

Hello everybody, I already used the ‘struct’ as an equivalent of class (say for Python or C++, or …) but I didn’t find what is the trick of Julia to emulate the ‘class-variable’ that is the variable which belongs to all…

---

## [Parameter estimation ODE with custom Loss function](https://discourse.julialang.org/t/parameter-estimation-ode-with-custom-loss-function/124835)

<div class="topic-metadata">

**Author:** [@Marta\_Pardo\_Araujo](https://discourse.julialang.org/u/Marta_Pardo_Araujo)\
**Replies:** 2\
**Last updated:** [January 24, 2025, 3:11pm UTC](https://discourse.julialang.org/t/parameter-estimation-ode-with-custom-loss-function/124835 "2025-01-24T15:11:31Z")

</div>

Hi, I am trying to estimate the parameters of my systems of ODE’s. I have done it before using the L2Loss() and it worked. Now I would like to do a custom loss function where I take the mean of the solutions of the Odes …

---

## [Understanding macro lexical bindings](https://discourse.julialang.org/t/understanding-macro-lexical-bindings/125105)

<div class="topic-metadata">

**Author:** [@nietzsche](https://discourse.julialang.org/u/nietzsche)\
**Replies:** 2\
**Last updated:** [January 23, 2025, 12:59pm UTC](https://discourse.julialang.org/t/understanding-macro-lexical-bindings/125105 "2025-01-23T12:59:55Z")

</div>

Hello, the macroexpand in the code below lead to an Error. UndefVarError: i not defined Ther error is clear, but how can I solve it? Or how can I put the “i” from the for loop in the right environment? macro dlamdba(…

---

## [Sum over tuple slower than sum over array](https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 3\
**Last updated:** [January 24, 2025, 12:34pm UTC](https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162 "2025-01-24T12:34:18Z")

</div>

Hi there, I wrote a trivial sum function: function my\_sum(collection) s = zero(eltype(collection)) for i in eachindex(collection) s += collection\[i\] end return s end When I apply it to a tuple …

---

## [Dispatch size static array: looking for good examples](https://discourse.julialang.org/t/dispatch-size-static-array-looking-for-good-examples/125138)

<div class="topic-metadata">

**Author:** [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)\
**Replies:** 1\
**Last updated:** [January 24, 2025, 9:12am UTC](https://discourse.julialang.org/t/dispatch-size-static-array-looking-for-good-examples/125138 "2025-01-24T09:12:40Z")

</div>

Given a struct defining an element, e.g., using StaticArrays const Point2D = SVector{2,Float64}; # struct to hold a single mesh element struct Element p1::Point2D # coordinates first node p2::Po…

---

## [Bug in sleep() function - main thread work affecting sleep duration on running tasks](https://discourse.julialang.org/t/bug-in-sleep-function-main-thread-work-affecting-sleep-duration-on-running-tasks/101911)

<div class="topic-metadata">

**Author:** [@algunion](https://discourse.julialang.org/u/algunion)\
**Replies:** 47\
**Last updated:** [January 23, 2025, 8:36pm UTC](https://discourse.julialang.org/t/bug-in-sleep-function-main-thread-work-affecting-sleep-duration-on-running-tasks/101911 "2025-01-23T20:36:44Z")

</div>

What triggered the present experiment was my failure to find a reasonable solution for the issue raised by this topic. It turned out that the issue was unrelated to the HTTP.jl package and went deeper. Now, the experim…

---

## [Precompilation error in cluster](https://discourse.julialang.org/t/precompilation-error-in-cluster/125083)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 10\
**Last updated:** [January 23, 2025, 7:52pm UTC](https://discourse.julialang.org/t/precompilation-error-in-cluster/125083 "2025-01-23T19:52:48Z")

</div>

Any idea what can be going on here? \[lmartine@coaraci ~\]$ julia +1.10 --startup-file=no \_ \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ …

---

## [Intriguing performance comparison results.... threads, comprehensions, etc](https://discourse.julialang.org/t/intriguing-performance-comparison-results-threads-comprehensions-etc/125093)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 11\
**Last updated:** [January 23, 2025, 7:03pm UTC](https://discourse.julialang.org/t/intriguing-performance-comparison-results-threads-comprehensions-etc/125093 "2025-01-23T19:03:56Z")

</div>

Can anyone provide me with intuition for the poor performance of the dynamic threads for loop in the example below? (all second run times) Thanks! using LinearAlgebra, .Threads function test( Y, ::Val{1} ) X = …

---

## [How to access the monotonic "steady" clock?](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 2\
**Last updated:** [January 23, 2025, 6:10pm UTC](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078 "2025-01-23T18:10:31Z")

</div>

POSIX systems offer a “system clock”, represented as time since the UNIX epoch (1-1-1970), nowadays usually represented with a nanoseconds resolution. There’s also supposed to be a “monotonic clock”, also known as “stead…

---

## [Memory leak in Julia 1.11.x](https://discourse.julialang.org/t/memory-leak-in-julia-1-11-x/125120)

<div class="topic-metadata">

**Author:** [@Miroboru](https://discourse.julialang.org/u/Miroboru)\
**Replies:** 6\
**Last updated:** [January 23, 2025, 3:18pm UTC](https://discourse.julialang.org/t/memory-leak-in-julia-1-11-x/125120 "2025-01-23T15:18:55Z")

</div>

I have a simulation written in Julia that I have been developing and running for a few years. It is a rather complex simulation with runtimes measured in days when using multicore computers, and it relies mainly on Flux,…

---

## [SymPy makes REPL to stuck](https://discourse.julialang.org/t/sympy-makes-repl-to-stuck/124814)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 19\
**Last updated:** [January 23, 2025, 2:47pm UTC](https://discourse.julialang.org/t/sympy-makes-repl-to-stuck/124814 "2025-01-23T14:47:43Z")

</div>

When I tried the following in REPL, it gets stuck when I types the last line. I cannot keep typing. The command top shows that Julia is using all the CPU. Any suggestion on how to trouble shoot the problem? I thought it…

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

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