# General Usage

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

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

**Page:** 161

---

## [Emptying figures in makie](https://discourse.julialang.org/t/emptying-figures-in-makie/115425)

<div class="topic-metadata">

**Author:** [@Davidbarber](https://discourse.julialang.org/u/Davidbarber)\
**Replies:** 5\
**Last updated:** [June 11, 2024, 9:54am UTC](https://discourse.julialang.org/t/emptying-figures-in-makie/115425 "2024-06-11T09:54:55Z")

</div>

I have created a figure in GLMakie with an image and an IntervalSlider to adjust contrast. This works fine. If I empty the figure with empty!(fig) and then recreate the image plot object and the IntervalSlider plot objec…

---

## [Increasing the markersize of the legend](https://discourse.julialang.org/t/increasing-the-markersize-of-the-legend/81928)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 4\
**Last updated:** [June 11, 2024, 5:36am UTC](https://discourse.julialang.org/t/increasing-the-markersize-of-the-legend/81928 "2024-06-11T05:36:35Z")

</div>

In Makie, how do you increase the markersize of the legend, even though the markersize used in the plot is small? I have a scatter plot with many points so I set a small marker size. But the same markersize in the legen…

---

## [FiniteDiff, ForwardDiff and Enzyme disagree: who is right?](https://discourse.julialang.org/t/finitediff-forwarddiff-and-enzyme-disagree-who-is-right/115441)

<div class="topic-metadata">

**Author:** [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Replies:** 9\
**Last updated:** [June 10, 2024, 11:37pm UTC](https://discourse.julialang.org/t/finitediff-forwarddiff-and-enzyme-disagree-who-is-right/115441 "2024-06-10T23:37:36Z")

</div>

As mentioned in the title, FiniteDiff, ForwardDiff and Enzyme return different results for the following code. Any ideas what is going wrong and which partial derivatives are correct? using Pkg Pkg.activate(temp = true)…

---

## [Julia thinks inverse of a Hermitian matrix is not Hermitian](https://discourse.julialang.org/t/julia-thinks-inverse-of-a-hermitian-matrix-is-not-hermitian/115443)

<div class="topic-metadata">

**Author:** [@archisman](https://discourse.julialang.org/u/archisman)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 8:51pm UTC](https://discourse.julialang.org/t/julia-thinks-inverse-of-a-hermitian-matrix-is-not-hermitian/115443 "2024-06-10T20:51:44Z")

</div>

Here is my code: using LinearAlgebra a = randn(50,50); a = (a+a')/2; println(ishermitian(a)) println(ishermitian(inv(a))) The output is True False However, the inverse of a Hermitian matrix is supposed to be Hermiti…

---

## [How to avoid memory blow up with FFT without expensive garbage collection?](https://discourse.julialang.org/t/how-to-avoid-memory-blow-up-with-fft-without-expensive-garbage-collection/115400)

<div class="topic-metadata">

**Author:** [@singularity](https://discourse.julialang.org/u/singularity)\
**Replies:** 3\
**Last updated:** [June 10, 2024, 7:55pm UTC](https://discourse.julialang.org/t/how-to-avoid-memory-blow-up-with-fft-without-expensive-garbage-collection/115400 "2024-06-10T19:55:33Z")

</div>

I am trying to write a code that has a for loop inside which an array is broken into chunks, sent to multiple processors, and FFT is performed on those chunks. Without using garbage collection GC.gc() command at the end …

---

## [Union type constructor question](https://discourse.julialang.org/t/union-type-constructor-question/115433)

<div class="topic-metadata">

**Author:** [@slwu89](https://discourse.julialang.org/u/slwu89)\
**Replies:** 3\
**Last updated:** [June 10, 2024, 4:34pm UTC](https://discourse.julialang.org/t/union-type-constructor-question/115433 "2024-06-10T16:34:35Z")

</div>

Can someone help explain to me why the first line produces an error but the second works? On v1.10.3, thanks! julia\> Union{Int,Symbol}(5) ERROR: MethodError: no method matching Union{Int64, Symbol}(::Int64) Stacktrace: …

---

## [Query regarding namespaces when adding a method using a macro](https://discourse.julialang.org/t/query-regarding-namespaces-when-adding-a-method-using-a-macro/115392)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 2:07pm UTC](https://discourse.julialang.org/t/query-regarding-namespaces-when-adding-a-method-using-a-macro/115392 "2024-06-10T14:07:24Z")

</div>

I am confused about how namespaces are being applied in the following code, and would appreciate some help. module A using LinearAlgebra abstract type AbsType end struct SubType \<: AbsType end macro newmethod() quo…

---

## [Why is Julia allocating when accessing these structs?](https://discourse.julialang.org/t/why-is-julia-allocating-when-accessing-these-structs/89905)

<div class="topic-metadata">

**Author:** [@dellagd](https://discourse.julialang.org/u/dellagd)\
**Replies:** 18\
**Last updated:** [June 10, 2024, 2:05pm UTC](https://discourse.julialang.org/t/why-is-julia-allocating-when-accessing-these-structs/89905 "2024-06-10T14:05:05Z")

</div>

Been struggling to figure out why accesses to these struct fields are causing memory allocations. Here is my test code: module AllocationsTest struct SubStruct a::Float64 b::Float64 end struct AllocationsStruc…

---

## [Efficient operations on vectors of static things](https://discourse.julialang.org/t/efficient-operations-on-vectors-of-static-things/115387)

<div class="topic-metadata">

**Author:** [@ddcampayo](https://discourse.julialang.org/u/ddcampayo)\
**Replies:** 12\
**Last updated:** [June 10, 2024, 11:27am UTC](https://discourse.julialang.org/t/efficient-operations-on-vectors-of-static-things/115387 "2024-06-10T11:27:36Z")

</div>

Hello. I am (still) trying to make sense on how to efficiently traverse a vector containing static vectors and matrices and doing operations on them. This is in the context of molecular dynamics, where I have N particle…

---

## [Scalar Indexing with CUDA](https://discourse.julialang.org/t/scalar-indexing-with-cuda/115379)

<div class="topic-metadata">

**Author:** [@Jason\_Meziere](https://discourse.julialang.org/u/Jason_Meziere)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 8:04am UTC](https://discourse.julialang.org/t/scalar-indexing-with-cuda/115379 "2024-06-10T08:04:01Z")

</div>

I have a portion of my code that I haven’t quite figured out how to do without scalar indexing. I was messing around in the repl and noticed that, while something like a\[1\]=1 will give the scalar indexing warning, some…

---

## [Best/simplest way to calculate sparse Hessian](https://discourse.julialang.org/t/best-simplest-way-to-calculate-sparse-hessian/58629)

<div class="topic-metadata">

**Author:** [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 7:01am UTC](https://discourse.julialang.org/t/best-simplest-way-to-calculate-sparse-hessian/58629 "2024-06-10T07:01:34Z")

</div>

I’ve got a log-probability density function of multiple variables, and would like to integrate it using a Laplace approximation. To do this I need to find the function’s maximum and calculate the Hessian at that point. …

---

## [Writing an equivalent Julia mutable struct that have similar functionality of a Python class](https://discourse.julialang.org/t/writing-an-equivalent-julia-mutable-struct-that-have-similar-functionality-of-a-python-class/115406)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 5:10am UTC](https://discourse.julialang.org/t/writing-an-equivalent-julia-mutable-struct-that-have-similar-functionality-of-a-python-class/115406 "2024-06-10T05:10:25Z")

</div>

I have the following Python class with a class counter and self-referential assignment as follows: class Foo(object): counter = 0 # a class attributeinitialized to 0 that is shared across all instances of the clas…

---

## [Question about PKG](https://discourse.julialang.org/t/question-about-pkg/115393)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [June 9, 2024, 3:06pm UTC](https://discourse.julialang.org/t/question-about-pkg/115393 "2024-06-09T15:06:40Z")

</div>

Why can’t I install these Pkg? thank you！

---

## [How to get help with plot parameters](https://discourse.julialang.org/t/how-to-get-help-with-plot-parameters/115357)

<div class="topic-metadata">

**Author:** [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Replies:** 2\
**Last updated:** [June 10, 2024, 1:15am UTC](https://discourse.julialang.org/t/how-to-get-help-with-plot-parameters/115357 "2024-06-10T01:15:37Z")

</div>

using Plots x = \[2\] scalars = \[-2 1 2\] vals = \[0 0 0; x \* scalars\] labels= \[(-3.6, -4.2, "-2x"), (2.4, 1.8, "x"), (4.4, 3.8, "2x")\] plot(vals, vals, arrow= true, color= \[:red :red :blue\], legend = :none, xlims = (-5,…

---

## [MPI-related pre compilation errors](https://discourse.julialang.org/t/mpi-related-pre-compilation-errors/115405)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 0\
**Last updated:** [June 10, 2024, 12:30am UTC](https://discourse.julialang.org/t/mpi-related-pre-compilation-errors/115405 "2024-06-10T00:30:48Z")

</div>

Is this known? Julia 1.10.4 on Linux (examples) pkg\> precompile HDF5 Precompiling HDF5 Info Given HDF5 was explicitly requested, output will be shown live ERROR: LoadError: InitError: could not load library "/ho…

---

## [How to initialize a tensor with permutational symmetry?](https://discourse.julialang.org/t/how-to-initialize-a-tensor-with-permutational-symmetry/115390)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 1\
**Last updated:** [June 9, 2024, 1:52pm UTC](https://discourse.julialang.org/t/how-to-initialize-a-tensor-with-permutational-symmetry/115390 "2024-06-09T13:52:44Z")

</div>

I am working on a iterative solver for non linear Coupled Cluster equations that would require a computation of lot of tensor elements via tensor contractions. For now, I am using the TensorOperations.jl for this purpose…

---

## [Equivalent Julia code for a Python class with counter variables](https://discourse.julialang.org/t/equivalent-julia-code-for-a-python-class-with-counter-variables/115385)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 2\
**Last updated:** [June 9, 2024, 9:30am UTC](https://discourse.julialang.org/t/equivalent-julia-code-for-a-python-class-with-counter-variables/115385 "2024-06-09T09:30:03Z")

</div>

Consider the following Python code from the link # Python code class Student: # A student ID counter idCounter = 0 def \_\_init\_\_(self): self.gpa = 0 self.record = {} # Each time I crea…

---

## [How to conditionally add new features](https://discourse.julialang.org/t/how-to-conditionally-add-new-features/115335)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 7\
**Last updated:** [June 9, 2024, 5:05am UTC](https://discourse.julialang.org/t/how-to-conditionally-add-new-features/115335 "2024-06-09T05:05:52Z")

</div>

Lets say i have a package with a type and methods module Core abstract type AbstractInterfaceType end foo(a::AbstractType) = println("do interface stuff") struct MyBaseType \<: AbstractInterfaceType end …

---

## [LD\_PRELOAD does not override malloc\_usable\_size from glibc](https://discourse.julialang.org/t/ld-preload-does-not-override-malloc-usable-size-from-glibc/115369)

<div class="topic-metadata">

**Author:** [@remysucre](https://discourse.julialang.org/u/remysucre)\
**Replies:** 0\
**Last updated:** [June 8, 2024, 7:24pm UTC](https://discourse.julialang.org/t/ld-preload-does-not-override-malloc-usable-size-from-glibc/115369 "2024-06-08T19:24:29Z")

</div>

I’m trying to override glibc’s malloc\_usable\_size, but it seems LD\_PRELOAD doesn’t work. To replicate on linux (glibc): Save the following content in rmalloc.c: #include \<stddef.h\> #include \<stdio.h\> size\_t malloc\_usa…

---

## [Set with type with custom equality](https://discourse.julialang.org/t/set-with-type-with-custom-equality/115364)

<div class="topic-metadata">

**Author:** [@JonasKoziorek](https://discourse.julialang.org/u/JonasKoziorek)\
**Replies:** 3\
**Last updated:** [June 8, 2024, 5:19pm UTC](https://discourse.julialang.org/t/set-with-type-with-custom-equality/115364 "2024-06-08T17:19:15Z")

</div>

I have a type whose instance is equivalent to instances that are in some distance away: struct VectorWithEpsRadius{T} value::T eps::Float64 end function ==(a::VectorWithEpsRadius, b::VectorWithEpsRadius) re…

---

## [Random number reproducibility from Poisson distribution](https://discourse.julialang.org/t/random-number-reproducibility-from-poisson-distribution/115359)

<div class="topic-metadata">

**Author:** [@mgp](https://discourse.julialang.org/u/mgp)\
**Replies:** 2\
**Last updated:** [June 8, 2024, 3:54pm UTC](https://discourse.julialang.org/t/random-number-reproducibility-from-poisson-distribution/115359 "2024-06-08T15:54:35Z")

</div>

I want to sample a series of random numbers from Poisson distributions, such as using Distributions, Random Random.seed!(1) rand(Poisson(10)) # 9 rand(Poisson(11)) # 12 rand(Poisson(12)) # 9 rand(Poisson(13)) # 17 …

---

## [Making images as big as possible (max width) in pluto notebooks](https://discourse.julialang.org/t/making-images-as-big-as-possible-max-width-in-pluto-notebooks/115003)

<div class="topic-metadata">

**Author:** [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Replies:** 14\
**Last updated:** [June 8, 2024, 3:35pm UTC](https://discourse.julialang.org/t/making-images-as-big-as-possible-max-width-in-pluto-notebooks/115003 "2024-06-08T15:35:03Z")

</div>

I am doing some image analysis in Pluto and everythign is amazing… except I can’t control how big the images are! I have the obligatory column embiggener html code at the top html"""\<style\> main { max-width: 96%; …

---

## [Getting Stack Overflow error when running Derivative(x)^n](https://discourse.julialang.org/t/getting-stack-overflow-error-when-running-derivative-x-n/115300)

<div class="topic-metadata">

**Author:** [@vikram\_backup](https://discourse.julialang.org/u/vikram_backup)\
**Replies:** 5\
**Last updated:** [June 8, 2024, 11:11am UTC](https://discourse.julialang.org/t/getting-stack-overflow-error-when-running-derivative-x-n/115300 "2024-06-08T11:11:58Z")

</div>

I have published my code in the following link. I am pasting my code here as well ## using Symbolics using Plots using Statistics ## a = 0.529\*10^-10 # Radius of hydrogen atom in meters function Legrande(l::Int, cosθ:…

---

## [PackageCompiler and Plots.jl: ld warning and 16KB image](https://discourse.julialang.org/t/packagecompiler-and-plots-jl-ld-warning-and-16kb-image/115312)

<div class="topic-metadata">

**Author:** [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Replies:** 3\
**Last updated:** [June 8, 2024, 10:53am UTC](https://discourse.julialang.org/t/packagecompiler-and-plots-jl-ld-warning-and-16kb-image/115312 "2024-06-08T10:53:59Z")

</div>

I am on a Mac (M3) with Sonoma (14.4.1), running Julia v1.10.4 and trying to use PackageCompiler.jl (v2.1.17) with Plots.jl (v1.40.4). Note I get into the same troubles with any other package I am trying to “prepackage”. …

---

## [Do I need a macro to compile a list of functions?](https://discourse.julialang.org/t/do-i-need-a-macro-to-compile-a-list-of-functions/112540)

<div class="topic-metadata">

**Author:** [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Replies:** 30\
**Last updated:** [April 25, 2024, 5:01pm UTC](https://discourse.julialang.org/t/do-i-need-a-macro-to-compile-a-list-of-functions/112540 "2024-04-25T17:01:10Z")

</div>

I have a bunch of related functions that I expand from time to time. They are grouped into files. I would like to put into an array all functions in a file, so that I can call them in a loop. Can this be accomplished wit…

---

## [Problem with static\_unpack](https://discourse.julialang.org/t/problem-with-static-unpack/115320)

<div class="topic-metadata">

**Author:** [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Replies:** 2\
**Last updated:** [June 8, 2024, 7:15am UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320 "2024-06-08T07:15:15Z")

</div>

Dearests, I found that the very first example for the macro at-static\_unpack of ComponentArrays is not working julia\> x = ComponentArray(a=5, b=\[4, 1\], c = \[1 2; 3 4\], d=(e=2, f=\[6, 30.0\])) ComponentVector{Float64}(a =…

---

## [Reuse Tridiagonal LU decomposition](https://discourse.julialang.org/t/reuse-tridiagonal-lu-decomposition/115149)

<div class="topic-metadata">

**Author:** [@bclyons12](https://discourse.julialang.org/u/bclyons12)\
**Replies:** 3\
**Last updated:** [June 8, 2024, 6:20am UTC](https://discourse.julialang.org/t/reuse-tridiagonal-lu-decomposition/115149 "2024-06-08T06:20:59Z")

</div>

I need to perform a loop of linear solves with different matrices and vectors, but the same Tridiagonal structure. I’d like to do this without allocations in the loop. Is there anyway to preallocate the Tridiagonal LU da…

---

## [Confusing behaviour of include("source.jl") in parallel codes](https://discourse.julialang.org/t/confusing-behaviour-of-include-source-jl-in-parallel-codes/115295)

<div class="topic-metadata">

**Author:** [@singularity](https://discourse.julialang.org/u/singularity)\
**Replies:** 6\
**Last updated:** [June 7, 2024, 6:40pm UTC](https://discourse.julialang.org/t/confusing-behaviour-of-include-source-jl-in-parallel-codes/115295 "2024-06-07T18:40:46Z")

</div>

Julia’s rules when writing parallelized codes have caused a lot of frustration since I started using Julia many years ago. I have encountered another issue today. When using @everywhere workers() with the include("source…

---

## [Type instability when solving ODEProblem](https://discourse.julialang.org/t/type-instability-when-solving-odeproblem/105687)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 3\
**Last updated:** [June 7, 2024, 3:57pm UTC](https://discourse.julialang.org/t/type-instability-when-solving-odeproblem/105687 "2024-06-07T15:57:26Z")

</div>

Hello, in the following I show a minimal working example of the problem. I want to implement a type stable function that solves an ODE. But I figured out that the solve function returns Any type. This is the minimal code…

---

## [Why is usage of llvmcall so restricted?](https://discourse.julialang.org/t/why-is-usage-of-llvmcall-so-restricted/115274)

<div class="topic-metadata">

**Author:** [@aramend](https://discourse.julialang.org/u/aramend)\
**Replies:** 12\
**Last updated:** [June 7, 2024, 2:56pm UTC](https://discourse.julialang.org/t/why-is-usage-of-llvmcall-so-restricted/115274 "2024-06-07T14:56:33Z")

</div>

Hi all. I would otherwise post in Internals & Design but I’m not allowed to. So I’ve looked around the discourse and elsewhere but would still like to better know why llvmcall works the way it does, and if there are othe…

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

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