# General Usage

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

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

**Page:** 329

---

## [IfElse doesn't work properly when using @turbo](https://discourse.julialang.org/t/ifelse-doesnt-work-properly-when-using-turbo/94639)

<div class="topic-metadata">

**Author:** [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Replies:** 3\
**Last updated:** [February 14, 2023, 11:08pm UTC](https://discourse.julialang.org/t/ifelse-doesnt-work-properly-when-using-turbo/94639 "2023-02-14T23:08:53Z")

</div>

function iftest(x) bestIndex = 0 minValue = Inf @turbo for i in eachindex(x) bestIndex = ifelse(x\[i\] \< minValue, i, bestIndex) minValue = min(x\[i\], minValue) end return minValue, bestI…

---

## [Optimal layouting with DataAspect()](https://discourse.julialang.org/t/optimal-layouting-with-dataaspect/75121)

<div class="topic-metadata">

**Author:** [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)\
**Replies:** 9\
**Last updated:** [February 14, 2023, 9:50pm UTC](https://discourse.julialang.org/t/optimal-layouting-with-dataaspect/75121 "2023-02-14T21:50:44Z")

</div>

I’m currently trying to create multipanel plots that all use DataAspect() and I’ve been wondering if there’s a clever way to generate the optimal layout. Here’s an example: The panels are created such that all data li…

---

## [NamedArray - reducing over an empty collection error - VS Code](https://discourse.julialang.org/t/namedarray-reducing-over-an-empty-collection-error-vs-code/94624)

<div class="topic-metadata">

**Author:** [@mdogan](https://discourse.julialang.org/u/mdogan)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 8:30pm UTC](https://discourse.julialang.org/t/namedarray-reducing-over-an-empty-collection-error-vs-code/94624 "2023-02-14T20:30:27Z")

</div>

On VS Code: I am trying to create a named array, but it throws this error: ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying init to the reducer My code is: using NamedArrays Na…

---

## [Proper way to plot a linear combination](https://discourse.julialang.org/t/proper-way-to-plot-a-linear-combination/94632)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 4\
**Last updated:** [February 14, 2023, 6:50pm UTC](https://discourse.julialang.org/t/proper-way-to-plot-a-linear-combination/94632 "2023-02-14T18:50:22Z")

</div>

Hello, good afternoon. Im trying to plot a linear combination in a 3d plane, subset of two vectors, with julia and plots and I’m failing with this tasks. Julia plots works a bit different than matplotlib. What is the c…

---

## [How to interrupt (not kill) julia from the REPL?](https://discourse.julialang.org/t/how-to-interrupt-not-kill-julia-from-the-repl/22565)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 25\
**Last updated:** [February 14, 2023, 6:50pm UTC](https://discourse.julialang.org/t/how-to-interrupt-not-kill-julia-from-the-repl/22565 "2023-02-14T18:50:04Z")

</div>

From the REPL, how do I interrupt execution of a function? Basically, I want to press some command key and cause it to throw an error that I can catch. For example: function interruptable\_loop() try while not\_don…

---

## [DiffEqGPU throws InvalidIR Error for simple example](https://discourse.julialang.org/t/diffeqgpu-throws-invalidir-error-for-simple-example/94579)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 3\
**Last updated:** [February 14, 2023, 4:56pm UTC](https://discourse.julialang.org/t/diffeqgpu-throws-invalidir-error-for-simple-example/94579 "2023-02-14T16:56:16Z")

</div>

Hi, my minimal example for DiffEqGPU.jl does not work unfortunately. The MWE is (copy paste in Pluto): # ╔═╡ fd1a977c-abca-11ed-2e82-315cc1b1716b using DifferentialEquations, Zygote, CUDA,DiffEqGPU, StaticArrays # ╔═…

---

## [Creating a struct from a Named Tuple](https://discourse.julialang.org/t/creating-a-struct-from-a-named-tuple/94586)

<div class="topic-metadata">

**Author:** [@alfaromartino](https://discourse.julialang.org/u/alfaromartino)\
**Replies:** 7\
**Last updated:** [February 14, 2023, 2:15pm UTC](https://discourse.julialang.org/t/creating-a-struct-from-a-named-tuple/94586 "2023-02-14T14:15:36Z")

</div>

Is there any function like similar which creates a struct inhering the names and types of a NamedTuple? MEW: nt = (a = 1, b ="Hello") #some function like MyStruct = similar(nt) #\`similar\` would create this: struct M…

---

## [Error when using sparse Jacobians/Krylov solvers in RadauIIA methods](https://discourse.julialang.org/t/error-when-using-sparse-jacobians-krylov-solvers-in-radauiia-methods/94629)

<div class="topic-metadata">

**Author:** [@wpowell96](https://discourse.julialang.org/u/wpowell96)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 4:20pm UTC](https://discourse.julialang.org/t/error-when-using-sparse-jacobians-krylov-solvers-in-radauiia-methods/94629 "2023-02-14T16:20:24Z")

</div>

Yesterday I posted an issue but realized that I forgot to crosspost this here for visibility. I was trying to generate some work-precision diagrams for MOL PDEs based on this old SciML benchmark. The syntax for declarin…

---

## [List of use´d or import'ed modules in a Julia session](https://discourse.julialang.org/t/list-of-use-d-or-imported-modules-in-a-julia-session/94584)

<div class="topic-metadata">

**Author:** [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Replies:** 9\
**Last updated:** [February 14, 2023, 2:18pm UTC](https://discourse.julialang.org/t/list-of-use-d-or-imported-modules-in-a-julia-session/94584 "2023-02-14T14:18:33Z")

</div>

Hi there I would like to understand a little bit more about the answer to the question implied on the title of this topic of mine, as per the following question from StackOverflow: List of loaded/imported packages in Ju…

---

## [How to ask in source for a backtrace](https://discourse.julialang.org/t/how-to-ask-in-source-for-a-backtrace/94616)

<div class="topic-metadata">

**Author:** [@pao](https://discourse.julialang.org/u/pao)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 11:15am UTC](https://discourse.julialang.org/t/how-to-ask-in-source-for-a-backtrace/94616 "2023-02-14T11:15:02Z")

</div>

Is there any macro or function to get a local becktrace, i.e., the stack of calls porting the execution there at run-ime? Thanks for help.

---

## [Function Composition Strategies](https://discourse.julialang.org/t/function-composition-strategies/94571)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 5\
**Last updated:** [February 14, 2023, 11:02am UTC](https://discourse.julialang.org/t/function-composition-strategies/94571 "2023-02-14T11:02:05Z")

</div>

In my project ExpandNestedData.jl, I need to compose a series of Iterator functions that are unique for any given input. I was using Iterators.repeat, Iterators.flatten, etc. but since each of these returns a parametrize…

---

## [How to define trainable weights in Flux](https://discourse.julialang.org/t/how-to-define-trainable-weights-in-flux/94617)

<div class="topic-metadata">

**Author:** [@Xuekui\_wang](https://discourse.julialang.org/u/Xuekui_wang)\
**Replies:** 0\
**Last updated:** [February 14, 2023, 10:39am UTC](https://discourse.julialang.org/t/how-to-define-trainable-weights-in-flux/94617 "2023-02-14T10:39:29Z")

</div>

I want to define a network mode with W=\[w11 0 w13; 0 w22 0; w31 0 w33\], i.e. set some weights to fixed number and they are not trained, for example m3 = Chain(Dense(3,3), Dense(3,2)) how to set m3.layer\[1\].weights, a…

---

## [Consecutive findmin and findmax](https://discourse.julialang.org/t/consecutive-findmin-and-findmax/94419)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 6\
**Last updated:** [February 14, 2023, 8:12am UTC](https://discourse.julialang.org/t/consecutive-findmin-and-findmax/94419 "2023-02-14T08:12:13Z")

</div>

I want to find the index of an element after consecutive min and max operations. I have a working code, but it’s ugly and probably inefficient since it makes unneeded iterations. Also it’s not flexible, in the sense it…

---

## [Fill area under 3d curve PlotlyJS.jl](https://discourse.julialang.org/t/fill-area-under-3d-curve-plotlyjs-jl/94556)

<div class="topic-metadata">

**Author:** [@Maucejo](https://discourse.julialang.org/u/Maucejo)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 5:44am UTC](https://discourse.julialang.org/t/fill-area-under-3d-curve-plotlyjs-jl/94556 "2023-02-14T05:44:03Z")

</div>

Dear all, I struggle with a problem for a few days. Indeed, I am trying to fill the area under a 3d curve using PlotlyJS without any success. Here is the MWE: using PlotlyJS x = range(0., 2π, 100) z = sin.(x) X = \[0…

---

## [\`solve(prob,Optim.BFGS())\` requires \`using OptimizationOptimJL](https://discourse.julialang.org/t/solve-prob-optim-bfgs-requires-using-optimizationoptimjl/94544)

<div class="topic-metadata">

**Author:** [@qjulia](https://discourse.julialang.org/u/qjulia)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 4:58am UTC](https://discourse.julialang.org/t/solve-prob-optim-bfgs-requires-using-optimizationoptimjl/94544 "2023-02-14T04:58:17Z")

</div>

Hello, I am using the following two lines and OptimizationOptimJL is installed. using OptimizationOptimJL; optimized\_sol\_nn2 = Optimization.solve(optprob, optimized\_sol\_nn.minimizer, Optim.BFGS(initial\_stepnorm=0.001),…

---

## [For loop on the elements of a mutable struct](https://discourse.julialang.org/t/for-loop-on-the-elements-of-a-mutable-struct/94563)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 9\
**Last updated:** [February 13, 2023, 8:46pm UTC](https://discourse.julialang.org/t/for-loop-on-the-elements-of-a-mutable-struct/94563 "2023-02-13T20:46:14Z")

</div>

Hi ! :smiley: I have a question about mutable structs. I have a model model composed of several compartments, each characterized by (say) 2 values a and b. I would like to make a for loop to test different values of a …

---

## [How to install a python package automatically in my package?](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581)

<div class="topic-metadata">

**Author:** [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Replies:** 3\
**Last updated:** [February 13, 2023, 8:14pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581 "2023-02-13T20:14:13Z")

</div>

Hi everyone, I am writing a small package for a personel project. It is dependant on a python package that is wrapping another code written in Fortran. I know how to install it via pip in PyCall.jl and it works great. …

---

## [Ploting LARGE heatmaps? Plots.jl in GPU?](https://discourse.julialang.org/t/ploting-large-heatmaps-plots-jl-in-gpu/94033)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 12\
**Last updated:** [February 13, 2023, 7:20pm UTC](https://discourse.julialang.org/t/ploting-large-heatmaps-plots-jl-in-gpu/94033 "2023-02-13T19:20:37Z")

</div>

Hi all. I have this matrix that has a size of 3250x55650 and it is just a sample of my raw data. I have a few files much larger. I need to make heatmaps but Plots.jl is a bit slow on CPU when I run these lines p1=he…

---

## [Change a vector CartesianIndex](https://discourse.julialang.org/t/change-a-vector-cartesianindex/94506)

<div class="topic-metadata">

**Author:** [@Zerosum](https://discourse.julialang.org/u/Zerosum)\
**Replies:** 8\
**Last updated:** [February 13, 2023, 6:53pm UTC](https://discourse.julialang.org/t/change-a-vector-cartesianindex/94506 "2023-02-13T18:53:07Z")

</div>

I was wondering if I could get help with this problem. I have a matrix and find every index where its value is negative. mat = \[1 2 3 ; -1 -2 3\] ind = findall(\<(0),mat) 2-element Vector{CartesianIndex{2}}: Cartesian…

---

## [Using Split ODE Solvers within Method of Steps](https://discourse.julialang.org/t/using-split-ode-solvers-within-method-of-steps/94569)

<div class="topic-metadata">

**Author:** [@wpowell96](https://discourse.julialang.org/u/wpowell96)\
**Replies:** 2\
**Last updated:** [February 13, 2023, 5:39pm UTC](https://discourse.julialang.org/t/using-split-ode-solvers-within-method-of-steps/94569 "2023-02-13T17:39:21Z")

</div>

I am interesting in simulating delayed reaction-diffusion equations of the form u\_t = \\Delta u + f(u,u(t-\\tau)) in a 2-D spatial domain of modest size (10,000 equations) and a non-stiff nonlinearity (for now). My curre…

---

## [Is it safe declare lock as module constant?](https://discourse.julialang.org/t/is-it-safe-declare-lock-as-module-constant/94507)

<div class="topic-metadata">

**Author:** [@harsh\_kumar](https://discourse.julialang.org/u/harsh_kumar)\
**Replies:** 3\
**Last updated:** [February 13, 2023, 4:03pm UTC](https://discourse.julialang.org/t/is-it-safe-declare-lock-as-module-constant/94507 "2023-02-13T16:03:18Z")

</div>

I have created a package that uses a spin lock and I have declared this as module constant (example shown below). Since Julia compiles the package, it will declare the constant only once. Will this cause any unexpected i…

---

## [The naming of \`allunique\` in DataFrames.jl](https://discourse.julialang.org/t/the-naming-of-allunique-in-dataframes-jl/94568)

<div class="topic-metadata">

**Author:** [@alfaromartino](https://discourse.julialang.org/u/alfaromartino)\
**Replies:** 3\
**Last updated:** [February 12, 2023, 9:27am UTC](https://discourse.julialang.org/t/the-naming-of-allunique-in-dataframes-jl/94568 "2023-02-12T09:27:21Z")

</div>

Although it’s probably too late, a name like uniquerows would be more self-explanatory than allunique. Thanks for your excellent work!

---

## [Multidimensional arrays as indices in setindex!: bug or feature?](https://discourse.julialang.org/t/multidimensional-arrays-as-indices-in-setindex-bug-or-feature/94558)

<div class="topic-metadata">

**Author:** [@Az9DBvyVLWBjs8g](https://discourse.julialang.org/u/Az9DBvyVLWBjs8g)\
**Replies:** 1\
**Last updated:** [February 13, 2023, 2:29pm UTC](https://discourse.julialang.org/t/multidimensional-arrays-as-indices-in-setindex-bug-or-feature/94558 "2023-02-13T14:29:56Z")

</div>

Hello everyone, I just found that one can use multidimensional arrays as indices within setindex!. They behave as 1d arrays, which is different from their behavior in getindex, thus the following assertion from the docs …

---

## [Not able to run Julia through python on a server in a frontend type application](https://discourse.julialang.org/t/not-able-to-run-julia-through-python-on-a-server-in-a-frontend-type-application/89431)

<div class="topic-metadata">

**Author:** [@shwetank\_verma](https://discourse.julialang.org/u/shwetank_verma)\
**Replies:** 3\
**Last updated:** [February 13, 2023, 2:04pm UTC](https://discourse.julialang.org/t/not-able-to-run-julia-through-python-on-a-server-in-a-frontend-type-application/89431 "2023-02-13T14:04:35Z")

</div>

Hey everyone, I am not able to find anything on this so I will try to explain as many things as I can. We are building a cloud-based simulation application whose frontend is Javascript which is calling python script. T…

---

## [How to initialize array of arrays with specific type?](https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557)

<div class="topic-metadata">

**Author:** [@CeterisPartybus](https://discourse.julialang.org/u/CeterisPartybus)\
**Replies:** 7\
**Last updated:** [February 13, 2023, 1:46pm UTC](https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557 "2023-02-13T13:46:26Z")

</div>

Hi everyone, I would like to initialize an array that is later filled with interpolation objects. To be specific, it should store output from interpolate() from Interpolations.jl later on. Normally, I can initialize an…

---

## [Data structure for convenient access to tabular data](https://discourse.julialang.org/t/data-structure-for-convenient-access-to-tabular-data/94523)

<div class="topic-metadata">

**Author:** [@bbrunaud](https://discourse.julialang.org/u/bbrunaud)\
**Replies:** 5\
**Last updated:** [February 13, 2023, 1:26pm UTC](https://discourse.julialang.org/t/data-structure-for-convenient-access-to-tabular-data/94523 "2023-02-13T13:26:18Z")

</div>

Hello community I use Julia to build JuMP models. What you usually have is indexed parameters that I would like to store in DataFrames and have convenient access when writing models. Think of a DataFrame where you have …

---

## [Using Plots, is there a simple way to plot a 3D cube/rectangle?](https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [February 12, 2023, 6:49pm UTC](https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528 "2023-02-12T18:49:19Z")

</div>

Hello! I found this nice function online: rectangle(w, h, x, y) = Shape(x .+ \[0,w,w,0\], y .+ \[0,0,h,h\]) Which can produce: x = y = 1 w = h = 1 plot(rectangle(w, h, x, y)) Does anyone know how to produce a 3d equi…

---

## [From Scmil\_train to Optimization.jl](https://discourse.julialang.org/t/from-scmil-train-to-optimization-jl/94316)

<div class="topic-metadata">

**Author:** [@qjulia](https://discourse.julialang.org/u/qjulia)\
**Replies:** 26\
**Last updated:** [February 13, 2023, 12:07pm UTC](https://discourse.julialang.org/t/from-scmil-train-to-optimization-jl/94316 "2023-02-13T12:07:23Z")

</div>

Hello, I am trying to write the following line: optimized\_sol\_nn = DiffEqFlux.sciml\_train(p -\> cost\_adjoint\_nn(p, 0.08), θ\_nn,RADAM(0.003), maxiters = 1000) with Optimization.jl package since scmil\_train is deprecated…

---

## [Enabling broadcasting for named tuples alt. broadcast? broadcasted? broadcastable? BroadcastStyle?](https://discourse.julialang.org/t/enabling-broadcasting-for-named-tuples-alt-broadcast-broadcasted-broadcastable-broadcaststyle/94468)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 1\
**Last updated:** [February 13, 2023, 11:59am UTC](https://discourse.julialang.org/t/enabling-broadcasting-for-named-tuples-alt-broadcast-broadcasted-broadcastable-broadcaststyle/94468 "2023-02-13T11:59:44Z")

</div>

Like many before me (if my googling serves me right), I found myself in need of broadcasting over named tuples. In this case it is in the hope that I can get MLUtils.jl to handle batches that are (you guessed it) named t…

---

## [Best way to write dense rank-one update?](https://discourse.julialang.org/t/best-way-to-write-dense-rank-one-update/3929)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 9\
**Last updated:** [February 13, 2023, 10:38am UTC](https://discourse.julialang.org/t/best-way-to-write-dense-rank-one-update/3929 "2023-02-13T10:38:36Z")

</div>

For a rank-one update of a dense matrix in Matlab, I would write A=A+u\*v'. If I just use the same Matlab statement in Julia, I’ll get poor performance because of needless memory allocation and copying. I know how to wr…

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

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