# General Usage

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

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

**Page:** 116

---

## [Make mutable struct read-only in local scope](https://discourse.julialang.org/t/make-mutable-struct-read-only-in-local-scope/122244)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 1\
**Last updated:** [November 4, 2024, 5:55pm UTC](https://discourse.julialang.org/t/make-mutable-struct-read-only-in-local-scope/122244 "2024-11-04T17:55:55Z")

</div>

Is there a way to make a mutable-struct read-only in a given scope? (I don’t need that to be strictly impossible, just not user-friendly). Something like having: struct A x::Vector{Int} end and making it hard to u…

---

## [Array of Structs vs Structs of Arrays](https://discourse.julialang.org/t/array-of-structs-vs-structs-of-arrays/122227)

<div class="topic-metadata">

**Author:** [@hssn15](https://discourse.julialang.org/u/hssn15)\
**Replies:** 1\
**Last updated:** [November 4, 2024, 3:16pm UTC](https://discourse.julialang.org/t/array-of-structs-vs-structs-of-arrays/122227 "2024-11-04T15:16:58Z")

</div>

Hi, I have a question about data storing. I am developing numerical simulator and need to store variables (temporarily) for each iterations. Those variables change in each iterations. But I am not sure what kind of sto…

---

## [Generalized Eigenvalue Problem with singular matrix](https://discourse.julialang.org/t/generalized-eigenvalue-problem-with-singular-matrix/121759)

<div class="topic-metadata">

**Author:** [@Alejandra-CB](https://discourse.julialang.org/u/Alejandra-CB)\
**Replies:** 16\
**Last updated:** [November 4, 2024, 1:20pm UTC](https://discourse.julialang.org/t/generalized-eigenvalue-problem-with-singular-matrix/121759 "2024-11-04T13:20:40Z")

</div>

Hello everyone! I am currently working on a generalized eigenvalue problem, defined by the equation Aϕ=λBϕ, where matrix B is singular. Both matrices A and B are defined as sparse matrices, as I aim to apply this script…

---

## [Update jll library](https://discourse.julialang.org/t/update-jll-library/122202)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 2\
**Last updated:** [November 4, 2024, 6:44am UTC](https://discourse.julialang.org/t/update-jll-library/122202 "2024-11-04T06:44:29Z")

</div>

The DuckDB\_jll library is at 1.1.0: This library seems to be the reason for a failing precompilation of DuckDB.jl on windows, as reported in this issue. The last comment in that issue suggest the following fix: If …

---

## [Internals of assignment when doing short circuit evaluation](https://discourse.julialang.org/t/internals-of-assignment-when-doing-short-circuit-evaluation/122178)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 8\
**Last updated:** [November 4, 2024, 1:48am UTC](https://discourse.julialang.org/t/internals-of-assignment-when-doing-short-circuit-evaluation/122178 "2024-11-04T01:48:57Z")

</div>

I am doing short circuit evaluation as an if then statement. But I am unsure of how it works so that, even if the second term of the “and” operation is not a boolean value, it works and it returns the value (it executes …

---

## [Truth values, precedence and arithmetic operators](https://discourse.julialang.org/t/truth-values-precedence-and-arithmetic-operators/122200)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 3\
**Last updated:** [November 3, 2024, 7:40pm UTC](https://discourse.julialang.org/t/truth-values-precedence-and-arithmetic-operators/122200 "2024-11-03T19:40:15Z")

</div>

While making a code, I had the following condition to throw an error: n\<0 | !isa(n,Integer) For n=3.0, the code was giving false. Though it took me a while, I now understand that “|” takes precedence. Even though, in t…

---

## [Using @fastmath](https://discourse.julialang.org/t/using-fastmath/122203)

<div class="topic-metadata">

**Author:** [@hssn15](https://discourse.julialang.org/u/hssn15)\
**Replies:** 1\
**Last updated:** [November 3, 2024, 7:09pm UTC](https://discourse.julialang.org/t/using-fastmath/122203 "2024-11-03T19:09:24Z")

</div>

Hi, I have started to use @fastmath to have fast computations for polynomials. It was great when I pass Float64. But when i pass dual number (e.g. ForwardDiff.Dual(1., 1.)), i noticed that there is no any speed up. Do y…

---

## [Evaluation order of Threads.nthreads()](https://discourse.julialang.org/t/evaluation-order-of-threads-nthreads/121989)

<div class="topic-metadata">

**Author:** [@lkdvos](https://discourse.julialang.org/u/lkdvos)\
**Replies:** 3\
**Last updated:** [November 3, 2024, 1:33pm UTC](https://discourse.julialang.org/t/evaluation-order-of-threads-nthreads/121989 "2024-11-03T13:33:29Z")

</div>

I have found some unexpected behavior when trying to capture the result of Threads.nthreads(). The use-case is the following: module MyModule # some algorithms that may or may not use multithreading # Default settings …

---

## [CI fails to build GLMakie dependency](https://discourse.julialang.org/t/ci-fails-to-build-glmakie-dependency/80125)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 9\
**Last updated:** [November 3, 2024, 12:56pm UTC](https://discourse.julialang.org/t/ci-fails-to-build-glmakie-dependency/80125 "2024-11-03T12:56:55Z")

</div>

I am trying to set up a CI pipeline for a package that depends on GLMakie. So far this fails with ERROR: LoadError: Failed to precompile GLMakie \[e9467ef8-e4e7-5192-8a1a-b1aee30e663a\] to /home/runner/.julia/compiled/v1.…

---

## [Passing Constants into Functions as local variables vs default parameters or global constants](https://discourse.julialang.org/t/passing-constants-into-functions-as-local-variables-vs-default-parameters-or-global-constants/122177)

<div class="topic-metadata">

**Author:** [@hssn15](https://discourse.julialang.org/u/hssn15)\
**Replies:** 7\
**Last updated:** [November 3, 2024, 11:24am UTC](https://discourse.julialang.org/t/passing-constants-into-functions-as-local-variables-vs-default-parameters-or-global-constants/122177 "2024-11-03T11:24:33Z")

</div>

I am writing Module that calculates thermodynamic properties of water. Module consists of lots of functions and each function requires 34 constant values. Fortunately, those parameters are same for all functions. Curren…

---

## [Learn to use Symbolics.jl](https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190)

<div class="topic-metadata">

**Author:** [@pywugate](https://discourse.julialang.org/u/pywugate)\
**Replies:** 1\
**Last updated:** [November 3, 2024, 10:57am UTC](https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190 "2024-11-03T10:57:29Z")

</div>

Hi , I want to use Symbolics.jl to solve bo and b1 from 2 equations b0 + b1 \* x1 = y1 b0 + b1 \* x2 = y2 I know in SymPy.jl it would be using SymPy @syms x\[1:2\] y\[1:2\] b\[0:1\] eqns = \[one.(x) x\] \* b .~ y solve(eqns, b)…

---

## [\`gui\` does not work with Jupyter Notebooks](https://discourse.julialang.org/t/gui-does-not-work-with-jupyter-notebooks/122194)

<div class="topic-metadata">

**Author:** [@tillfalko](https://discourse.julialang.org/u/tillfalko)\
**Replies:** 2\
**Last updated:** [November 3, 2024, 10:09am UTC](https://discourse.julialang.org/t/gui-does-not-work-with-jupyter-notebooks/122194 "2024-11-03T10:09:37Z")

</div>

One of my main frustrations with Julia is that the same code will behave differently on the REPL vs IJulia vs executed directly. Why does the code using Plots gui(plot(randn(10))) work on the REPL, but not in my Noteb…

---

## [How to generate a correct VTS grid using WriteVTK.jl?](https://discourse.julialang.org/t/how-to-generate-a-correct-vts-grid-using-writevtk-jl/122022)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 5\
**Last updated:** [November 3, 2024, 10:00am UTC](https://discourse.julialang.org/t/how-to-generate-a-correct-vts-grid-using-writevtk-jl/122022 "2024-11-03T10:00:14Z")

</div>

Hello! I have the following code: using WriteVTK # Cell dimensions dx = 1.0 dy = 1.0 # Initialize lists for storing points and connectivity points = Vector{SVector{3, Float64}}() # List to store unique SVector poin…

---

## [A quick and dirty tool for generating \`Project.toml\`](https://discourse.julialang.org/t/a-quick-and-dirty-tool-for-generating-project-toml/11375)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 23\
**Last updated:** [November 3, 2024, 9:31am UTC](https://discourse.julialang.org/t/a-quick-and-dirty-tool-for-generating-project-toml/11375 "2024-11-03T09:31:44Z")

</div>

I wrote this simple tool for generating a Project.toml to make your Julia package compliant with the new Pkg. Just load up this module (put the file in your LOAD\_PATH and do using GenProject, head over to the directory …

---

## [Rewrite printf with print](https://discourse.julialang.org/t/rewrite-printf-with-print/122193)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 1\
**Last updated:** [November 3, 2024, 8:45am UTC](https://discourse.julialang.org/t/rewrite-printf-with-print/122193 "2024-11-03T08:45:06Z")

</div>

Hello, using Printf function twoTimesTable() for h = 1 : 12 @printf("%2d x 2 = %2d\\n", h, h\*2) end end # twoTimesTable twoTimesTable() How can I make this printf with print? Thank you.

---

## [Calling a variable in println](https://discourse.julialang.org/t/calling-a-variable-in-println/122168)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 3\
**Last updated:** [November 3, 2024, 7:01am UTC](https://discourse.julialang.org/t/calling-a-variable-in-println/122168 "2024-11-03T07:01:26Z")

</div>

Hello, I want to multiply the numbers 1 to 12 by 2. How can I change the following code so that this operation happens in println? for a=1 : 12 println("$a \* 2") end Thank you.

---

## [Cannot get package directory with dependencies to work](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 3\
**Last updated:** [November 2, 2024, 11:36pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187 "2024-11-02T23:36:19Z")

</div>

Here is an example: I create a directory ~/Julia/ExamplePackage with a Project.toml \[deps\] MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" and a file src/ExamplePackage.jl with contents module ExamplePackage using…

---

## [Using Let block](https://discourse.julialang.org/t/using-let-block/110490)

<div class="topic-metadata">

**Author:** [@co1emi11er](https://discourse.julialang.org/u/co1emi11er)\
**Replies:** 15\
**Last updated:** [November 2, 2024, 6:33pm UTC](https://discourse.julialang.org/t/using-let-block/110490 "2024-11-02T18:33:41Z")

</div>

If I define a variable b in Main and then use the let block: b = 5 let b = b println(b) end I get the error saying: " UndefVarError: b not defined" I can get this to work by doing: b = 5 let b = Main.b prin…

---

## [\`minimum()\` 3x - 6x slower than \`numpy.min()\`](https://discourse.julialang.org/t/minimum-3x-6x-slower-than-numpy-min/121889)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 16\
**Last updated:** [November 2, 2024, 5:15pm UTC](https://discourse.julialang.org/t/minimum-3x-6x-slower-than-numpy-min/121889 "2024-11-02T17:15:20Z")

</div>

I think there are enough issues on github and nothing is moving so I’m not gonna spam there, but putting here to see if people have a temporary solution: julia\> using Chairmarks julia\> @be rand(Float32, 512000) minimum…

---

## [MATLAB Image Segmentation Algorithm Gives Empty Images in Julia?](https://discourse.julialang.org/t/matlab-image-segmentation-algorithm-gives-empty-images-in-julia/122156)

<div class="topic-metadata">

**Author:** [@matividalg](https://discourse.julialang.org/u/matividalg)\
**Replies:** 7\
**Last updated:** [November 2, 2024, 4:36pm UTC](https://discourse.julialang.org/t/matlab-image-segmentation-algorithm-gives-empty-images-in-julia/122156 "2024-11-02T16:36:43Z")

</div>

Hi there! I’m using the DICOM, FileIO, ImageMagick and other packages to load DICOM images for segmentation, but I just seem unable to. I’ve checked every post and even the repo. This is my code: using DICOM, Gtk4, Imag…

---

## [Array flattening function](https://discourse.julialang.org/t/array-flattening-function/122154)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 8\
**Last updated:** [November 2, 2024, 3:54pm UTC](https://discourse.julialang.org/t/array-flattening-function/122154 "2024-11-02T15:54:20Z")

</div>

I’m looking for the function that takes a (m,n) matrix of (k,l) matrices and makes a (m\*k, n\*l) matrix? And likewise for other dimensions. This works for 2d but it’s a little verbose. Is there a simpler and more general …

---

## [Plotting 2D histogram with different bins for each dimension](https://discourse.julialang.org/t/plotting-2d-histogram-with-different-bins-for-each-dimension/1790)

<div class="topic-metadata">

**Author:** [@rwgardner](https://discourse.julialang.org/u/rwgardner)\
**Replies:** 4\
**Last updated:** [November 2, 2024, 11:11am UTC](https://discourse.julialang.org/t/plotting-2d-histogram-with-different-bins-for-each-dimension/1790 "2024-11-02T11:11:22Z")

</div>

I’m trying to plot a 2D histogram where the 2 dimensions have different bins. I’m currently using marginalhist(x, x, fc=:plasma, bins=\[0.0, 1.0, 2.0\], legend=true) from PlotRecipes (although I’m not tied to that). Th…

---

## [Developing Julia on a moderate laptop is very tedious](https://discourse.julialang.org/t/developing-julia-on-a-moderate-laptop-is-very-tedious/121987)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 20\
**Last updated:** [November 2, 2024, 11:06am UTC](https://discourse.julialang.org/t/developing-julia-on-a-moderate-laptop-is-very-tedious/121987 "2024-11-02T11:06:16Z")

</div>

Hi there, I like to gather how other people develop julia packages. I so frequently run into the point where I changed a struct field name or const and need to restart julia, with compilation times which make me a bit s…

---

## [What's recommended literature on high-performance Julia?](https://discourse.julialang.org/t/whats-recommended-literature-on-high-performance-julia/122145)

<div class="topic-metadata">

**Author:** [@Olegg](https://discourse.julialang.org/u/Olegg)\
**Replies:** 6\
**Last updated:** [November 2, 2024, 6:31am UTC](https://discourse.julialang.org/t/whats-recommended-literature-on-high-performance-julia/122145 "2024-11-02T06:31:14Z")

</div>

There’s the book Julia High Performance: Optimizations, distributed computing, multithreading, and GPU programming with Julia 1.0 and beyond. 2nd edition from 2019. (It’s probably by @avik) Would it be useful for Julia …

---

## [How to call inplace (! convention) functions with JuliaCall?](https://discourse.julialang.org/t/how-to-call-inplace-convention-functions-with-juliacall/122155)

<div class="topic-metadata">

**Author:** [@marcsgil](https://discourse.julialang.org/u/marcsgil)\
**Replies:** 3\
**Last updated:** [November 1, 2024, 11:13pm UTC](https://discourse.julialang.org/t/how-to-call-inplace-convention-functions-with-juliacall/122155 "2024-11-01T23:13:31Z")

</div>

Hello! I’m trying to wrap a Julia package in Python using JuliaCall.jl. I have many functions in Julia that have both an in place version f!, and a corresponding out of place f. Unfortunately, one cannot have ! in as p…

---

## [Is there a sparse array with 'missing' as default](https://discourse.julialang.org/t/is-there-a-sparse-array-with-missing-as-default/122095)

<div class="topic-metadata">

**Author:** [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Replies:** 1\
**Last updated:** [October 31, 2024, 10:26pm UTC](https://discourse.julialang.org/t/is-there-a-sparse-array-with-missing-as-default/122095 "2024-10-31T22:26:58Z")

</div>

something like : \[missing,1.5,missing,missing\] where only 2 =\> 1.5 is stored?

---

## [Check if default sysimage is used](https://discourse.julialang.org/t/check-if-default-sysimage-is-used/122152)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 1\
**Last updated:** [November 1, 2024, 9:05pm UTC](https://discourse.julialang.org/t/check-if-default-sysimage-is-used/122152 "2024-11-01T21:05:42Z")

</div>

Is there a way to determine in Julia if the default system image or a custom system image is currently used?

---

## [How does one have multiple random variables in an SDEProblem?](https://discourse.julialang.org/t/how-does-one-have-multiple-random-variables-in-an-sdeproblem/122066)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 2\
**Last updated:** [November 1, 2024, 8:15pm UTC](https://discourse.julialang.org/t/how-does-one-have-multiple-random-variables-in-an-sdeproblem/122066 "2024-11-01T20:15:21Z")

</div>

I’m trying to simulate a stochastic state space model which looks something like: x\_dot(x) = A\*x + B\*u(x + n) + d A and B are matrices, x, n, and d are vectors and u is an affine function. Each of the elements of n an…

---

## [Threading over permutations](https://discourse.julialang.org/t/threading-over-permutations/122149)

<div class="topic-metadata">

**Author:** [@tg570](https://discourse.julialang.org/u/tg570)\
**Replies:** 2\
**Last updated:** [November 1, 2024, 8:12pm UTC](https://discourse.julialang.org/t/threading-over-permutations/122149 "2024-11-01T20:12:56Z")

</div>

I am trying to parallelize a loop over the Combinatorics permutations(1:n) without using collect() since the permutations I am working with are too big and they cause memory issues. I think there is a problem with just u…

---

## [Missing \`println\` output with \`wait(::Event); println("done")\`](https://discourse.julialang.org/t/missing-println-output-with-wait-event-println-done/122137)

<div class="topic-metadata">

**Author:** [@SunnyUser](https://discourse.julialang.org/u/SunnyUser)\
**Replies:** 3\
**Last updated:** [November 1, 2024, 6:21pm UTC](https://discourse.julialang.org/t/missing-println-output-with-wait-event-println-done/122137 "2024-11-01T18:21:09Z")

</div>

Hi all :slight\_smile: Can you check if the done2 is also missing for you? Here is my code: julia\> e = Base.Event() Base.Event(Base.GenericCondition{ReentrantLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Reen…

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

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