# General Usage

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

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

**Page:** 401

---

## [Sum of columns in julia dataframe and appen it as last element in the respective columns](https://discourse.julialang.org/t/sum-of-columns-in-julia-dataframe-and-appen-it-as-last-element-in-the-respective-columns/86837)

<div class="topic-metadata">

**Author:** [@ayodyas](https://discourse.julialang.org/u/ayodyas)\
**Replies:** 3\
**Last updated:** [September 6, 2022, 2:17pm UTC](https://discourse.julialang.org/t/sum-of-columns-in-julia-dataframe-and-appen-it-as-last-element-in-the-respective-columns/86837 "2022-09-06T14:17:33Z")

</div>

I have a dataframe df, using DataFrames df=DataFrame(p1 = \[1, 2, 3, 4, 5\],p2 = \[10,20,30,40,50\],p3 = \[5,5,10,20,20\]) I wanted to calculate the sum of specific columns (p1 and p2) and append it as the last row in respec…

---

## [Overriding (some?) key bindings in REPL does not seem to work](https://discourse.julialang.org/t/overriding-some-key-bindings-in-repl-does-not-seem-to-work/86830)

<div class="topic-metadata">

**Author:** [@HanD](https://discourse.julialang.org/u/HanD)\
**Replies:** 5\
**Last updated:** [September 6, 2022, 11:38am UTC](https://discourse.julialang.org/t/overriding-some-key-bindings-in-repl-does-not-seem-to-work/86830 "2022-09-06T11:38:33Z")

</div>

Hello! I’m trying to override a default keybinding in REPL, as suggested in the manual, with the following code in startup.jl: import REPL import REPL.LineEdit atreplinit() do repl my\_keys = Dict("^w" =\> (s,o...) …

---

## [Measuring non-idle time spent in process](https://discourse.julialang.org/t/measuring-non-idle-time-spent-in-process/86832)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 1\
**Last updated:** [September 6, 2022, 8:10am UTC](https://discourse.julialang.org/t/measuring-non-idle-time-spent-in-process/86832 "2022-09-06T08:10:49Z")

</div>

Hi all! I want to measure the non-idle time spent in a given process. If I use Julia’s wall clock with time(), other processes that run on my computer (like parallel threads) will change the measurement. Judging by the …

---

## [How to plot step function \[x\]/x Correctly with limit](https://discourse.julialang.org/t/how-to-plot-step-function-x-x-correctly-with-limit/86780)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 6\
**Last updated:** [September 6, 2022, 10:48am UTC](https://discourse.julialang.org/t/how-to-plot-step-function-x-x-correctly-with-limit/86780 "2022-09-06T10:48:02Z")

</div>

Hi all, I see a problem set and I want to plot this one: \\frac{\[x\]}{x} \[x\] is a step function I know the code to create step function (from my old thread), but how to create the above function? using Plots,LaTeXStri…

---

## ['tight\_layout' in Makie for plots with multiple subplots](https://discourse.julialang.org/t/tight-layout-in-makie-for-plots-with-multiple-subplots/86718)

<div class="topic-metadata">

**Author:** [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Replies:** 5\
**Last updated:** [September 6, 2022, 9:55am UTC](https://discourse.julialang.org/t/tight-layout-in-makie-for-plots-with-multiple-subplots/86718 "2022-09-06T09:55:25Z")

</div>

I have the following code: using CairoMakie # create data x = range(-1, 1, 129) y = range(-1, 1, 129) X = ones(length(y)) .\* x' Y = y .\* ones(1,length(x)) R = sqrt.(X.^2 + Y.^2) Z = ((R.^2 .- 1.5) .^ 2) Z\[R.\>1\] .= 0 …

---

## [How to passing vargs... to a function without allocation?](https://discourse.julialang.org/t/how-to-passing-vargs-to-a-function-without-allocation/86824)

<div class="topic-metadata">

**Author:** [@MrBug](https://discourse.julialang.org/u/MrBug)\
**Replies:** 4\
**Last updated:** [September 6, 2022, 9:54am UTC](https://discourse.julialang.org/t/how-to-passing-vargs-to-a-function-without-allocation/86824 "2022-09-06T09:54:05Z")

</div>

I would like to unpack a tuple parameter of a function, then pass it to another function. The naive implementation in the following causes allocations which becomes a bottleneck for my application. Is there any way to r…

---

## [Dagger use cases?](https://discourse.julialang.org/t/dagger-use-cases/72012)

<div class="topic-metadata">

**Author:** [@zsz00](https://discourse.julialang.org/u/zsz00)\
**Replies:** 6\
**Last updated:** [September 6, 2022, 8:07am UTC](https://discourse.julialang.org/t/dagger-use-cases/72012 "2022-09-06T08:07:04Z")

</div>

Obviously there are no upper-layer applications . As the user, It can’t be used to solve real problems.

---

## [Can I align all vertical axes in a multi-row faceted plot done with Plots.jl?](https://discourse.julialang.org/t/can-i-align-all-vertical-axes-in-a-multi-row-faceted-plot-done-with-plots-jl/86156)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 7\
**Last updated:** [September 6, 2022, 7:44am UTC](https://discourse.julialang.org/t/can-i-align-all-vertical-axes-in-a-multi-row-faceted-plot-done-with-plots-jl/86156 "2022-09-06T07:44:04Z")

</div>

I tried to do a faceted plot using Plots.jl. The code below does almost everything I wanted, except for one thing: the vertical axes are aligned on each row, but not across rows. The argument link = :y in the last Plot…

---

## [XGBoost Broken for Mac Mojave and earlier - Initialization Error](https://discourse.julialang.org/t/xgboost-broken-for-mac-mojave-and-earlier-initialization-error/86731)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 22\
**Last updated:** [September 6, 2022, 7:32am UTC](https://discourse.julialang.org/t/xgboost-broken-for-mac-mojave-and-earlier-initialization-error/86731 "2022-09-06T07:32:40Z")

</div>

I haven’t used XGBoost in a while. Now when I try to ‘use’ it, I get all sorts of errors, even when I update, and build, etc., even after fresh install of Julia. The difficulty seems to lie with c++ modules… Does anyon…

---

## [CUDA on slices](https://discourse.julialang.org/t/cuda-on-slices/86782)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 5\
**Last updated:** [September 6, 2022, 2:45am UTC](https://discourse.julialang.org/t/cuda-on-slices/86782 "2022-09-06T02:45:33Z")

</div>

Trying to apply a function to slices of a CuArray. Tried broadcasting, mapslices and various Tensor packages. Is there any way to do this? using CUDA, Pipe, Interpolations, TensorCast d = Uniform(1,30) x = Float64.(1…

---

## [\`GC.gc\` thread-safety?](https://discourse.julialang.org/t/gc-gc-thread-safety/86823)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [September 5, 2022, 9:58pm UTC](https://discourse.julialang.org/t/gc-gc-thread-safety/86823 "2022-09-05T21:58:16Z")

</div>

Is calling GC.gc() concurrently from multiple threads allowed? How about GC.gc(false)? I know the GC is stop-the-world, so doing that would diminish parallelism, I just want to know whether it’s correct to do so.

---

## [Docstring on multiple lines with a module that does not import Core and Base](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799)

<div class="topic-metadata">

**Author:** [@uje](https://discourse.julialang.org/u/uje)\
**Replies:** 7\
**Last updated:** [September 5, 2022, 7:33pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799 "2022-09-05T19:33:59Z")

</div>

I’m working on a module that does not import Core and Base to test a functionality. I’ve tried adding docstrings to the function the naive way, which I call “naive” because it doesn’t allow me the option of dispatching …

---

## [Advice on speeding up highly parallel and I/O intensive code](https://discourse.julialang.org/t/advice-on-speeding-up-highly-parallel-and-i-o-intensive-code/86795)

<div class="topic-metadata">

**Author:** [@snowgum](https://discourse.julialang.org/u/snowgum)\
**Replies:** 4\
**Last updated:** [September 5, 2022, 7:28pm UTC](https://discourse.julialang.org/t/advice-on-speeding-up-highly-parallel-and-i-o-intensive-code/86795 "2022-09-05T19:28:08Z")

</div>

I am solving a problem that is highly parallel, and wondering how to make it as efficient as possible in Julia. I need to run a function (let’s call it do\_work) on 1D slices of 3D arrays written on disk. For example, if …

---

## [Model identification for Cauer or Foster model](https://discourse.julialang.org/t/model-identification-for-cauer-or-foster-model/86767)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [September 5, 2022, 6:29pm UTC](https://discourse.julialang.org/t/model-identification-for-cauer-or-foster-model/86767 "2022-09-05T18:29:13Z")

</div>

How can I identify the parameters of the Cauer or Foster model based on a measured temperature over time curve? Source: Infineon application note The application note says: “as the coefficients can easily be extract…

---

## [Same code different result in let block and begin block](https://discourse.julialang.org/t/same-code-different-result-in-let-block-and-begin-block/86810)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 3\
**Last updated:** [September 5, 2022, 5:05pm UTC](https://discourse.julialang.org/t/same-code-different-result-in-let-block-and-begin-block/86810 "2022-09-05T17:05:56Z")

</div>

Hi, I have same code in both let block and begin block, but get totally different results, any suggestion for understand this? begin x = randn(100,10) function f() x = randn(2,2) return 1 e…

---

## [Difficulty defining promotion rules](https://discourse.julialang.org/t/difficulty-defining-promotion-rules/86787)

<div class="topic-metadata">

**Author:** [@chriswaudby](https://discourse.julialang.org/u/chriswaudby)\
**Replies:** 8\
**Last updated:** [September 5, 2022, 4:11pm UTC](https://discourse.julialang.org/t/difficulty-defining-promotion-rules/86787 "2022-09-05T16:11:02Z")

</div>

Hi, I’m trying to define promotion rules for a type representing multicomplex numbers (Multicomplex number - Wikipedia). These have a series of complex numbers, im1, im2, etc. Internally, these are represented as static…

---

## [How to vectorize only one argument in function call](https://discourse.julialang.org/t/how-to-vectorize-only-one-argument-in-function-call/86771)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 8\
**Last updated:** [September 5, 2022, 4:07pm UTC](https://discourse.julialang.org/t/how-to-vectorize-only-one-argument-in-function-call/86771 "2022-09-05T16:07:39Z")

</div>

Say I have a function that accepts several vectors f(a,b,c), but I have a vector of inputs for one of the arguments a. Can I call f like f(.a,b,c) such that f will vectorize only over a. Since if I call f.(a,b,c) f vect…

---

## [Fast optimized non dominated sorting algorithms](https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793)

<div class="topic-metadata">

**Author:** [@Michal\_Kvasnicka](https://discourse.julialang.org/u/Michal_Kvasnicka)\
**Replies:** 7\
**Last updated:** [September 5, 2022, 1:56pm UTC](https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793 "2022-09-05T13:56:32Z")

</div>

I am looking for any Julia fast non dominated sorting (NDS) code. I just found the following thread, but algorithms here are very naive with quadratic complexity and no parallelization. Are there any more sophisticated …

---

## [How can kwargs be used in multiple dispatch](https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 11\
**Last updated:** [September 5, 2022, 1:17pm UTC](https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790 "2022-09-05T13:17:19Z")

</div>

Multiple dispatch usually works on variable types, I presumed it could also work using kwargs, but it doesn’t seem to. How can I make this work? julia\> function shout(word::String; exclaim::Int) println(word …

---

## [Compare numbers at the stated precision](https://discourse.julialang.org/t/compare-numbers-at-the-stated-precision/86719)

<div class="topic-metadata">

**Author:** [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Replies:** 9\
**Last updated:** [September 5, 2022, 9:29am UTC](https://discourse.julialang.org/t/compare-numbers-at-the-stated-precision/86719 "2022-09-05T09:29:10Z")

</div>

In tests I’ll like to be able to write the following and the test to pass: @test aresame(pi, 3.14) The following works: @test isapprox(pi, 3.14, atol = 0.005) But then I need to adjust the absolute tolerance manual…

---

## [BenchmarkTools for benchmarking thread scalability of functions](https://discourse.julialang.org/t/benchmarktools-for-benchmarking-thread-scalability-of-functions/86711)

<div class="topic-metadata">

**Author:** [@gerhardu](https://discourse.julialang.org/u/gerhardu)\
**Replies:** 6\
**Last updated:** [September 5, 2022, 11:12am UTC](https://discourse.julialang.org/t/benchmarktools-for-benchmarking-thread-scalability-of-functions/86711 "2022-09-05T11:12:39Z")

</div>

I use BenchmarkTools.jl to benchmark functions in my code. That works great! But what I am missing is a good interface to analyze thread scalability. Is there an option in BenchmarkTools.jl or another package? As far a…

---

## [If blocks with code generation](https://discourse.julialang.org/t/if-blocks-with-code-generation/86506)

<div class="topic-metadata">

**Author:** [@gaspardb](https://discourse.julialang.org/u/gaspardb)\
**Replies:** 6\
**Last updated:** [September 5, 2022, 10:03am UTC](https://discourse.julialang.org/t/if-blocks-with-code-generation/86506 "2022-09-05T10:03:05Z")

</div>

Hi everyone, I’ve started Julia recently and stumbled upon a case which seemed well suited to metaprogramming. Use case With words: I have a train function which does roughly the same thing no matter the type of the mo…

---

## [\[Makie\] "MetaData array needs to have same length as data" error with observables and contourf](https://discourse.julialang.org/t/makie-metadata-array-needs-to-have-same-length-as-data-error-with-observables-and-contourf/86789)

<div class="topic-metadata">

**Author:** [@ManuelFossa](https://discourse.julialang.org/u/ManuelFossa)\
**Replies:** 2\
**Last updated:** [September 5, 2022, 9:44am UTC](https://discourse.julialang.org/t/makie-metadata-array-needs-to-have-same-length-as-data-error-with-observables-and-contourf/86789 "2022-09-05T09:44:04Z")

</div>

I try to plot an animation of contours with GLMakie and GeoMakie, using observables. This used to work , but I updated my Julia from 1.7.2 to 1.8 then it broke, with the error in the title occurring. I reverted to 1.7.2…

---

## [Weird output with REPL escape codes](https://discourse.julialang.org/t/weird-output-with-repl-escape-codes/86772)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 4\
**Last updated:** [September 5, 2022, 8:30am UTC](https://discourse.julialang.org/t/weird-output-with-repl-escape-codes/86772 "2022-09-05T08:30:16Z")

</div>

I’m trying to work with the raw output from a Julia process but I don’t understand even a simple version of it. I tried julia --banner=no | tee julia.txt, then typed 1+2 and enter. The file julia.txt then looks like thi…

---

## [Zygote and StaticArrays](https://discourse.julialang.org/t/zygote-and-staticarrays/86176)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 12\
**Last updated:** [September 5, 2022, 5:09am UTC](https://discourse.julialang.org/t/zygote-and-staticarrays/86176 "2022-09-05T05:09:08Z")

</div>

I am currently evaluating Zygote. My “usecase” is maybe a bit different from what has driven Zygote’s development: I want to take the gradient of scalar-valued functions of 10 to 100 inputes, but I will compute millions…

---

## [Interminnent errors throwing when adding procs](https://discourse.julialang.org/t/interminnent-errors-throwing-when-adding-procs/86778)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 1\
**Last updated:** [September 5, 2022, 2:07am UTC](https://discourse.julialang.org/t/interminnent-errors-throwing-when-adding-procs/86778 "2022-09-05T02:07:57Z")

</div>

I am on a cluster using Slurm as a workload scheduler. When I try to add processors: addprocs(SlurmManager(60), N=2, verbose="", topology=:master\_worker, exeflags="--project=.") it works about 2, 3 out of 10 tries. Mo…

---

## [Best practices for dealing with functions taking multiple vector variables](https://discourse.julialang.org/t/best-practices-for-dealing-with-functions-taking-multiple-vector-variables/86759)

<div class="topic-metadata">

**Author:** [@samerb](https://discourse.julialang.org/u/samerb)\
**Replies:** 5\
**Last updated:** [September 4, 2022, 3:50pm UTC](https://discourse.julialang.org/t/best-practices-for-dealing-with-functions-taking-multiple-vector-variables/86759 "2022-09-04T15:50:31Z")

</div>

Sometimes I want to use a function like f(x,y,z,w), where x,y,z,w are themselves vectors of potentially different lengths. But sometimes when I call solvers (e.g. NLSolve, Optim, Implicit Differentiation, JuMP) or other …

---

## [Error with 3-args dot based on FoldsCUDA](https://discourse.julialang.org/t/error-with-3-args-dot-based-on-foldscuda/86686)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 1\
**Last updated:** [September 4, 2022, 7:45am UTC](https://discourse.julialang.org/t/error-with-3-args-dot-based-on-foldscuda/86686 "2022-09-04T07:45:20Z")

</div>

Hi, I am trying to run a 3 args dot on GPU ( in fact CUDA). I am trying FoldsCUDA for simpler development of reductions but I dont understand why it errors on GPU but ot o CPU. Can someone give me a hint please? Thanks…

---

## [Macro to create struct problem](https://discourse.julialang.org/t/macro-to-create-struct-problem/86737)

<div class="topic-metadata">

**Author:** [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Replies:** 5\
**Last updated:** [September 4, 2022, 4:24am UTC](https://discourse.julialang.org/t/macro-to-create-struct-problem/86737 "2022-09-04T04:24:23Z")

</div>

Hello for compatibility with other library I need to create a struct with names of the fields supplied via list of Strings I tried sth like this structName="example\_struct" keyss= \["a","b","c"\] symbolKeys= map(key-\>Sym…

---

## [Using @lift with @sprintf for animation in Makie.jl](https://discourse.julialang.org/t/using-lift-with-sprintf-for-animation-in-makie-jl/86746)

<div class="topic-metadata">

**Author:** [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Replies:** 1\
**Last updated:** [September 4, 2022, 12:39am UTC](https://discourse.julialang.org/t/using-lift-with-sprintf-for-animation-in-makie-jl/86746 "2022-09-04T00:39:47Z")

</div>

I want to display a text box which acts as a counter in an animation. I followed the tutorial here, but the text I want to display consists of an integer and a really small number (which is visually better displayed usin…

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

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