# General Usage

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

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

**Page:** 99

---

## [Blackbox optim: customize stopping rule](https://discourse.julialang.org/t/blackbox-optim-customize-stopping-rule/124440)

<div class="topic-metadata">

**Author:** [@jgr](https://discourse.julialang.org/u/jgr)\
**Replies:** 0\
**Last updated:** [January 5, 2025, 5:44am UTC](https://discourse.julialang.org/t/blackbox-optim-customize-stopping-rule/124440 "2025-01-05T05:44:24Z")

</div>

Hi, I am using “bboptimize” in Julia for minimization. I tried to change the tolerance rule by setting FitnessTol=tol, result = bboptimize(funcblackbox; MaxSteps = maxiter, FitnessTol=tol) The problem I…

---

## [Get plot coordinates of a GLMakie mouse event](https://discourse.julialang.org/t/get-plot-coordinates-of-a-glmakie-mouse-event/124437)

<div class="topic-metadata">

**Author:** [@janonime](https://discourse.julialang.org/u/janonime)\
**Replies:** 0\
**Last updated:** [January 4, 2025, 11:26pm UTC](https://discourse.julialang.org/t/get-plot-coordinates-of-a-glmakie-mouse-event/124437 "2025-01-04T23:26:50Z")

</div>

It is easy to get the position of a mouse event in pixel coordinates: using GLMakie fig = Figure() ax = Axis(fig\[1,1\]) on(events(ax).mousebutton) do event if event.button == Mouse.left if event.action == M…

---

## [Neovim tree-sitter error when loading julia file: invalid node type "function\_expression"](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 8\
**Last updated:** [January 4, 2025, 6:58pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864 "2025-01-04T18:58:21Z")

</div>

After updating my neovim setup I get the following error My guess is I am not alone here (?) Searching a bit around I think a fix is already available from this commit But I don’t know when this will land to the l…

---

## [For loop performance vs "functional" performance](https://discourse.julialang.org/t/for-loop-performance-vs-functional-performance/124351)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 17\
**Last updated:** [January 4, 2025, 11:33am UTC](https://discourse.julialang.org/t/for-loop-performance-vs-functional-performance/124351 "2025-01-04T11:33:34Z")

</div>

The part 2 of the problem of day 19 of the AOC 2024 requires calculating the number of partitions of a string that are subsets of a given set of substrings. This is repeated for a list of strings and to obtain the total…

---

## [How to speedup setindex! and getindex?](https://discourse.julialang.org/t/how-to-speedup-setindex-and-getindex/124413)

<div class="topic-metadata">

**Author:** [@Thomas\_Van\_Giel](https://discourse.julialang.org/u/Thomas_Van_Giel)\
**Replies:** 3\
**Last updated:** [January 3, 2025, 8:50pm UTC](https://discourse.julialang.org/t/how-to-speedup-setindex-and-getindex/124413 "2025-01-03T20:50:58Z")

</div>

I have a piece of code where the setindex! and getindex function take a lot of time to execute. Quite simplified, the code looks a bit like this: using Random function main() A = rand(0:0.1:100000, 200,200) for s…

---

## [Kalman Filter with Enzyme](https://discourse.julialang.org/t/kalman-filter-with-enzyme/124264)

<div class="topic-metadata">

**Author:** [@charlesknipp](https://discourse.julialang.org/u/charlesknipp)\
**Replies:** 3\
**Last updated:** [January 3, 2025, 8:10pm UTC](https://discourse.julialang.org/t/kalman-filter-with-enzyme/124264 "2025-01-03T20:10:49Z")

</div>

Consider the simple problem of MLE on a linear Gaussian state space model using a Kalman filter. When properly designed, automatic differentiation should be a trivial task for achieving a log score; and for most backends…

---

## [Managing the arguments for nested function calls](https://discourse.julialang.org/t/managing-the-arguments-for-nested-function-calls/124414)

<div class="topic-metadata">

**Author:** [@prconlin](https://discourse.julialang.org/u/prconlin)\
**Replies:** 3\
**Last updated:** [January 3, 2025, 5:25pm UTC](https://discourse.julialang.org/t/managing-the-arguments-for-nested-function-calls/124414 "2025-01-03T17:25:37Z")

</div>

For the sake of performance and readability, I make an effort to compartmentalize my code into functions as much as possible. But I consistently run into a problem with ballooning argument lists whenever I have nested f…

---

## [Why Pluto.jl run so much faster than GenieFramework.jl](https://discourse.julialang.org/t/why-pluto-jl-run-so-much-faster-than-genieframework-jl/124234)

<div class="topic-metadata">

**Author:** [@garazha-ilya](https://discourse.julialang.org/u/garazha-ilya)\
**Replies:** 7\
**Last updated:** [January 3, 2025, 12:35pm UTC](https://discourse.julialang.org/t/why-pluto-jl-run-so-much-faster-than-genieframework-jl/124234 "2025-01-03T12:35:32Z")

</div>

I have a gauge animation with Plotly in Pluto and GenieFramework. But Pluto plots and tracks slider incredibly faster. Can someone help me with optimizations with Genie? Or explain, why it is fundamentally impossible. …

---

## [Help with Julia Integration in RStudio](https://discourse.julialang.org/t/help-with-julia-integration-in-rstudio/124374)

<div class="topic-metadata">

**Author:** [@Gael\_Gautier](https://discourse.julialang.org/u/Gael_Gautier)\
**Replies:** 3\
**Last updated:** [January 3, 2025, 10:04am UTC](https://discourse.julialang.org/t/help-with-julia-integration-in-rstudio/124374 "2025-01-03T10:04:56Z")

</div>

Hello, I’m encountering an issue with using Julia in RStudio and would appreciate your help in resolving it. I am using RStudio to write Quarto (qmd) scripts that include R, Python, and Bash code. However, due to the l…

---

## [\`ccall\` on Windows \`could not load symbol. The specified procedure could not be found\`](https://discourse.julialang.org/t/ccall-on-windows-could-not-load-symbol-the-specified-procedure-could-not-be-found/66291)

<div class="topic-metadata">

**Author:** [@nlaws](https://discourse.julialang.org/u/nlaws)\
**Replies:** 18\
**Last updated:** [January 3, 2025, 9:59am UTC](https://discourse.julialang.org/t/ccall-on-windows-could-not-load-symbol-the-specified-procedure-could-not-be-found/66291 "2025-01-03T09:59:59Z")

</div>

I am loading in a custom C library and then calling functions with @ccall. Everything works fine on Apple and Linux with: hdl = Libc.Libdl.dlopen("path/to/clibrary", Libc.Libdl.RTLD\_GLOBAL) wind\_module = @ccall ssc\_modu…

---

## [Inplace MPI\_Allreduce give wrong results. Solved: better doc is needed](https://discourse.julialang.org/t/inplace-mpi-allreduce-give-wrong-results-solved-better-doc-is-needed/124395)

<div class="topic-metadata">

**Author:** [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Replies:** 2\
**Last updated:** [January 3, 2025, 6:59am UTC](https://discourse.julialang.org/t/inplace-mpi-allreduce-give-wrong-results-solved-better-doc-is-needed/124395 "2025-01-03T06:59:58Z")

</div>

A MWE: using MPI a = \[1.0, 2.0, 3.0, 4.0\] MPI.Init() MPI.API.MPI\_Allreduce(MPI.API.MPI\_IN\_PLACE, a, 4, MPI.Datatype(Float64), MPI.Op(+, Float64), MPI.COMM\_WORLD) MPI.Finalize() println(a) which outputs \[NaN, 1.386670…

---

## [Improving error messages for structs](https://discourse.julialang.org/t/improving-error-messages-for-structs/124390)

<div class="topic-metadata">

**Author:** [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Replies:** 2\
**Last updated:** [January 3, 2025, 1:02am UTC](https://discourse.julialang.org/t/improving-error-messages-for-structs/124390 "2025-01-03T01:02:29Z")

</div>

If I have a situation like the following: struct Bar x::Float64 y::Float64 end Bar(missing, 2) then the error message doesn’t seem to indicate whether x or y was the problem: ERROR: LoadError: MethodError: Ca…

---

## [Using Unicode in README.md file?](https://discourse.julialang.org/t/using-unicode-in-readme-md-file/124097)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 6\
**Last updated:** [December 23, 2024, 8:46am UTC](https://discourse.julialang.org/t/using-unicode-in-readme-md-file/124097 "2024-12-23T08:46:26Z")

</div>

If I look at the README at this website: GitHub - baggepinnen/TrajectoryLimiters.jl: Nonlinear filters to create dynamically feasible reference trajectories with Firefox the unicode characters are very distorted and hard…

---

## [UndefVarError: \`𝕊ᶻ\` not defined](https://discourse.julialang.org/t/undefvarerror-not-defined/124380)

<div class="topic-metadata">

**Author:** [@JYOTI\_BISHT](https://discourse.julialang.org/u/JYOTI_BISHT)\
**Replies:** 2\
**Last updated:** [January 2, 2025, 5:31pm UTC](https://discourse.julialang.org/t/undefvarerror-not-defined/124380 "2025-01-02T17:31:38Z")

</div>

Hi Julia team, I am trying this trial code given on julia website to do exact diagonalization using QuantumLattices. The problem is: writing the following code it says UndefVarError: 𝕊ᶻ not defined using QuantumLattic…

---

## [GtkDropDown menu list update](https://discourse.julialang.org/t/gtkdropdown-menu-list-update/124355)

<div class="topic-metadata">

**Author:** [@daniel.flono](https://discourse.julialang.org/u/daniel.flono)\
**Replies:** 2\
**Last updated:** [January 2, 2025, 12:28pm UTC](https://discourse.julialang.org/t/gtkdropdown-menu-list-update/124355 "2025-01-02T12:28:37Z")

</div>

Hello Everyone, I am creating my first GUI and got stuck. I defined the GUI in xml format and then used GTK4 and the GtkBuilder in the Julia code. The window appears with no problem. I just can’t figure out how to chang…

---

## [Trying to understand Union{Nothing, Some{T}}](https://discourse.julialang.org/t/trying-to-understand-union-nothing-some-t/124348)

<div class="topic-metadata">

**Author:** [@modn4r](https://discourse.julialang.org/u/modn4r)\
**Replies:** 5\
**Last updated:** [January 2, 2025, 10:50am UTC](https://discourse.julialang.org/t/trying-to-understand-union-nothing-some-t/124348 "2025-01-02T10:50:14Z")

</div>

Hi, I am trying to understand the usage of the Some{T}: function test(x::Union{Some{Float64}, Nothing}) if isnothing(x) println("Nothing!") else println("Something!") end end test(nothing) #…

---

## [How to use a custom loss function with reactant?](https://discourse.julialang.org/t/how-to-use-a-custom-loss-function-with-reactant/124337)

<div class="topic-metadata">

**Author:** [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Replies:** 1\
**Last updated:** [January 1, 2025, 2:51pm UTC](https://discourse.julialang.org/t/how-to-use-a-custom-loss-function-with-reactant/124337 "2025-01-01T14:51:42Z")

</div>

I’m trying to make this code work, using MLDatasets,Lux,Reactant,Enzyme,Random,OneHotArrays,MLUtils,Optimisers,Statistics Reactant.set\_default\_backend("gpu") const rng = Random.MersenneTwister(123) const dev = xla\_devi…

---

## [Performance of for loop](https://discourse.julialang.org/t/performance-of-for-loop/124240)

<div class="topic-metadata">

**Author:** [@jgr](https://discourse.julialang.org/u/jgr)\
**Replies:** 7\
**Last updated:** [January 1, 2025, 2:06pm UTC](https://discourse.julialang.org/t/performance-of-for-loop/124240 "2025-01-01T14:06:52Z")

</div>

Hi, I want to run a for loop for matrix M with size (200,200,5). I have been told that for the sake of performance, it is better to loop from the outer to the inner (that is, dimension 3 → dim 2 → 1). But here the size …

---

## [Broadcasting the reshaped data @. versus .=](https://discourse.julialang.org/t/broadcasting-the-reshaped-data-versus/124300)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 13\
**Last updated:** [January 1, 2025, 11:48am UTC](https://discourse.julialang.org/t/broadcasting-the-reshaped-data-versus/124300 "2025-01-01T11:48:39Z")

</div>

I am rewriting this code below using broadcasting to improve performance and clarity. var = zeros(Float64, 9, 109, 50) data = rand(9\*109\*50) for j in 1:9 # Extract the slice of data corresponding to the current \`j\` …

---

## [Setting up Documenter for private Gitlab with PkgTemplates](https://discourse.julialang.org/t/setting-up-documenter-for-private-gitlab-with-pkgtemplates/124311)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 1\
**Last updated:** [December 31, 2024, 6:33pm UTC](https://discourse.julialang.org/t/setting-up-documenter-for-private-gitlab-with-pkgtemplates/124311 "2024-12-31T18:33:57Z")

</div>

I am setting up a repo on a private gitlab using PkgTemplates.jl. The CI worked with no problem, however, the documentation deployment is not working. I don’t know if I need to pass additional information to Documenter, …

---

## [Are recipes still an "advanced topic"?](https://discourse.julialang.org/t/are-recipes-still-an-advanced-topic/124217)

<div class="topic-metadata">

**Author:** [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Replies:** 6\
**Last updated:** [December 31, 2024, 11:47pm UTC](https://discourse.julialang.org/t/are-recipes-still-an-advanced-topic/124217 "2024-12-31T23:47:10Z")

</div>

I was recently trying to figure out how to let users of my code make some plots, without making Plots.jl (and its hefty list of dependencies) a dependency of the package. Recipes seem like they’re aimed at this use case…

---

## [RFC – ergonomic juliacall syntax for passing Python variables to Julia](https://discourse.julialang.org/t/rfc-ergonomic-juliacall-syntax-for-passing-python-variables-to-julia/124266)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 23\
**Last updated:** [December 31, 2024, 12:28am UTC](https://discourse.julialang.org/t/rfc-ergonomic-juliacall-syntax-for-passing-python-variables-to-julia/124266 "2024-12-31T00:28:04Z")

</div>

I want to get feedback on an API for ergonomically passing Python variables to Julia code via juliacall. Here are a couple of ideas: from juliacall import Main as jl # proposal jl.teval("const MY\_CONST = $(x)", x=my\_py…

---

## [QML and Examples not working](https://discourse.julialang.org/t/qml-and-examples-not-working/124293)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 2\
**Last updated:** [December 31, 2024, 1:18pm UTC](https://discourse.julialang.org/t/qml-and-examples-not-working/124293 "2024-12-31T13:18:31Z")

</div>

The discussion on GUI’s and in particular QML made me interested in trying it out to get a flavour of what it does and how to do it. So I went to the QML.jl page to try some examples. The first time through the gui.jl …

---

## [Not able to update for almost one week](https://discourse.julialang.org/t/not-able-to-update-for-almost-one-week/124247)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 11\
**Last updated:** [December 31, 2024, 11:34am UTC](https://discourse.julialang.org/t/not-able-to-update-for-almost-one-week/124247 "2024-12-31T11:34:11Z")

</div>

(@v1.7) pkg\> up Updating registry at \`C:\\Users\\ytian\\.julia\\registries\\General.toml\` ┌ Error: Some registries failed to update: │ — C:\\Users\\ytian\\.julia\\registries\\General.toml — failed to download from https://…

---

## [Interfaces.jl unable to find implementation](https://discourse.julialang.org/t/interfaces-jl-unable-to-find-implementation/124299)

<div class="topic-metadata">

**Author:** [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Replies:** 2\
**Last updated:** [December 31, 2024, 11:52am UTC](https://discourse.julialang.org/t/interfaces-jl-unable-to-find-implementation/124299 "2024-12-31T11:52:50Z")

</div>

Hi. I am trying to implement Interfaces.jl for my package. The code can be found here: SolarPosition.jl/src at main · PVSMC/SolarPosition.jl · GitHub The interface definition is here: SolarPosition.jl/src/PositionInte…

---

## [How is it possible that parallelized code causes fewer allocations?](https://discourse.julialang.org/t/how-is-it-possible-that-parallelized-code-causes-fewer-allocations/124161)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 19\
**Last updated:** [December 30, 2024, 5:41pm UTC](https://discourse.julialang.org/t/how-is-it-possible-that-parallelized-code-causes-fewer-allocations/124161 "2024-12-30T17:41:58Z")

</div>

This case baffles me: using StructArrays n, s = 10^5, 100; llp = \[rand(1:n,s) for \_=1:n\]; llw = \[rand(-1:0.001:1,s) for \_=1:n\] function sort\_vec!(pp::Vector{tp}, ww::Vector{tw}, by::Function=first) ::Nothing where {tp\<…

---

## [Memory caching for reducing allocations](https://discourse.julialang.org/t/memory-caching-for-reducing-allocations/124260)

<div class="topic-metadata">

**Author:** [@artemsolod](https://discourse.julialang.org/u/artemsolod)\
**Replies:** 6\
**Last updated:** [December 30, 2024, 5:16pm UTC](https://discourse.julialang.org/t/memory-caching-for-reducing-allocations/124260 "2024-12-30T17:16:05Z")

</div>

I am experimenting with the idea of automatically reusing memory from previous allocations. For some workloads like parameter search on fixed data I know that allocations will have the same size between iterations. Preal…

---

## [Julia and WASM](https://discourse.julialang.org/t/julia-and-wasm/108482)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 10\
**Last updated:** [December 30, 2024, 5:04pm UTC](https://discourse.julialang.org/t/julia-and-wasm/108482 "2024-12-30T17:04:48Z")

</div>

I thought this article on WASM and Julia was interesting and a good idea - maybe even inevitable. This is a short excerpt: Julia in WebAssembly by Raymond Minor Huffman B.S. in Computer Science and Engineering Massach…

---

## [Forecast Time series using Neural ODE for supervised learning](https://discourse.julialang.org/t/forecast-time-series-using-neural-ode-for-supervised-learning/124268)

<div class="topic-metadata">

**Author:** [@roilsed0903](https://discourse.julialang.org/u/roilsed0903)\
**Replies:** 0\
**Last updated:** [December 30, 2024, 5:59am UTC](https://discourse.julialang.org/t/forecast-time-series-using-neural-ode-for-supervised-learning/124268 "2024-12-30T05:59:43Z")

</div>

I’m aiming for time series prediction. I’ve seen a good prediction of time series through the post forcast weather NODE(“Forecasting the weather with neural ODEs” taked Sebastian Callh personal blog and “Forcasting time …

---

## [How I made a new, very hard logic puzzle using Julia](https://discourse.julialang.org/t/how-i-made-a-new-very-hard-logic-puzzle-using-julia/124262)

<div class="topic-metadata">

**Author:** [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Replies:** 0\
**Last updated:** [December 29, 2024, 11:56pm UTC](https://discourse.julialang.org/t/how-i-made-a-new-very-hard-logic-puzzle-using-julia/124262 "2024-12-29T23:56:02Z")

</div>

Here’s how I used Julia to make possibly one of the most difficult logic puzzles ever made. This one is truly diabolical. The question is that there are four gods, true, lie, rand, and rock. You can ask three questions…

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

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