# General Usage

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

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

**Page:** 258

---

## [Why is Julia faster than C++ for quicksort?](https://discourse.julialang.org/t/why-is-julia-faster-than-c-for-quicksort/102669)

<div class="topic-metadata">

**Author:** [@mariusd](https://discourse.julialang.org/u/mariusd)\
**Replies:** 15\
**Last updated:** [August 15, 2023, 3:24pm UTC](https://discourse.julialang.org/t/why-is-julia-faster-than-c-for-quicksort/102669 "2023-08-15T15:24:58Z")

</div>

See the following pieces of code for quicksort, adapted from GitHub - JuliaLang/Microbenchmarks: Microbenchmarks comparing the Julia Programming language with other languages. As you can see in the benchmark output, juli…

---

## [Makie @recipe need understanding](https://discourse.julialang.org/t/makie-recipe-need-understanding/102563)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 10\
**Last updated:** [August 15, 2023, 3:14pm UTC](https://discourse.julialang.org/t/makie-recipe-need-understanding/102563 "2023-08-15T15:14:09Z")

</div>

I’m having no luck finding a working example of how to define a makie @recipe for a custom type, or in this case custom types. I have a home grown quaternion and a 3D vector type which match better how legacy simulation…

---

## [@turbo Segfault with empty rows in SparseMatrix](https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821)

<div class="topic-metadata">

**Author:** [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Replies:** 1\
**Last updated:** [August 15, 2023, 1:17pm UTC](https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821 "2023-08-15T13:17:03Z")

</div>

I’m trying to use the @turbo macro from LoopVectorization iterating over values from a sparse array. The way I’m doing it is the following: I have a variable state::Vector{Float32} and a square sparse matrix holding Flo…

---

## [Slurping in not final position](https://discourse.julialang.org/t/slurping-in-not-final-position/102784)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 11\
**Last updated:** [August 15, 2023, 12:45pm UTC](https://discourse.julialang.org/t/slurping-in-not-final-position/102784 "2023-08-15T12:45:10Z")

</div>

I was running the roames notebook exercises, in an attempt to fix this: Create a more generic reduce2 function that works recursively over a tuple For the operations + and \*, being associative, simulate the operatio…

---

## [Help speeding up submatrix extraction from SparseCSC](https://discourse.julialang.org/t/help-speeding-up-submatrix-extraction-from-sparsecsc/102131)

<div class="topic-metadata">

**Author:** [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Replies:** 1\
**Last updated:** [August 15, 2023, 11:05am UTC](https://discourse.julialang.org/t/help-speeding-up-submatrix-extraction-from-sparsecsc/102131 "2023-08-15T11:05:14Z")

</div>

Hello again, I’d like to ask for help optimizing the extraction of a dense submatrix from a SparseCSC matrix. In other words, submatrix\_reference(spmat, rows, cols) = Matrix(spmat\[rows, cols\]) where spmat is a sparse …

---

## [Converting CartesianIndices to a vector of vectors](https://discourse.julialang.org/t/converting-cartesianindices-to-a-vector-of-vectors/102794)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 12\
**Last updated:** [August 15, 2023, 1:21am UTC](https://discourse.julialang.org/t/converting-cartesianindices-to-a-vector-of-vectors/102794 "2023-08-15T01:21:02Z")

</div>

I’m using CartesianIndices to generate lists resembling base-k numbers. I want the convert the output into a “flat” vector of vectors, irrespective of the number of “digits” passed to CartesianIndices. The lists will gen…

---

## [Google search console verification in Franklin.jl generated site](https://discourse.julialang.org/t/google-search-console-verification-in-franklin-jl-generated-site/72760)

<div class="topic-metadata">

**Author:** [@JaydevSR](https://discourse.julialang.org/u/JaydevSR)\
**Replies:** 3\
**Last updated:** [August 14, 2023, 11:20pm UTC](https://discourse.julialang.org/t/google-search-console-verification-in-franklin-jl-generated-site/72760 "2023-08-14T23:20:08Z")

</div>

I have been trying to verify my personal website made using Franklin.jl on the google search console platform but for some reason both of the two feasible methods don’t work: Meta tag in the head part of the site is no…

---

## [PlotlyJS.jl: grouped + stacked bar charts](https://discourse.julialang.org/t/plotlyjs-jl-grouped-stacked-bar-charts/102657)

<div class="topic-metadata">

**Author:** [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Replies:** 8\
**Last updated:** [August 14, 2023, 10:35pm UTC](https://discourse.julialang.org/t/plotlyjs-jl-grouped-stacked-bar-charts/102657 "2023-08-14T22:35:38Z")

</div>

Hi, I need to create a plot like the one below using PlotlyJS.jl. I have done my best and extensively searched this forum and others online. Still, there seems to be very little information about stacked + grouped bar c…

---

## [How to plot only the upper (or lower) triangle matrix in a heatmap?](https://discourse.julialang.org/t/how-to-plot-only-the-upper-or-lower-triangle-matrix-in-a-heatmap/102796)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 8\
**Last updated:** [August 14, 2023, 10:26pm UTC](https://discourse.julialang.org/t/how-to-plot-only-the-upper-or-lower-triangle-matrix-in-a-heatmap/102796 "2023-08-14T22:26:53Z")

</div>

Hello, folks I’m using a combination of functions plot() and heatmap() to visualize a correlation matrix. Correlation matrices, by definition, are symmetric, i.e., a\_{i,j} = a\_{j,i} for all i \\neq j. The diagonal, where…

---

## [DataFrame sort Performance using Query.jl vs SAS PROC SORT](https://discourse.julialang.org/t/dataframe-sort-performance-using-query-jl-vs-sas-proc-sort/41225)

<div class="topic-metadata">

**Author:** [@Dominic\_Pazzula](https://discourse.julialang.org/u/Dominic_Pazzula)\
**Replies:** 19\
**Last updated:** [August 11, 2023, 9:14pm UTC](https://discourse.julialang.org/t/dataframe-sort-performance-using-query-jl-vs-sas-proc-sort/41225 "2023-08-11T21:14:38Z")

</div>

I’m still learning Julia and am converting some SAS code. I have a large DataFrame (3.3M rows, 6 columns) that I am trying to sort. The performance compared to SAS is abysmal. function sort1(simstates) simstates2…

---

## [How to initialize and manipulate Dicts of Dicts?](https://discourse.julialang.org/t/how-to-initialize-and-manipulate-dicts-of-dicts/102788)

<div class="topic-metadata">

**Author:** [@trg818](https://discourse.julialang.org/u/trg818)\
**Replies:** 6\
**Last updated:** [August 14, 2023, 3:47pm UTC](https://discourse.julialang.org/t/how-to-initialize-and-manipulate-dicts-of-dicts/102788 "2023-08-14T15:47:30Z")

</div>

I am trying to initialize and manipulate Dicts of Dicts, starting with this one: using Dates clcdates=Date(2022,7):Month(1):Date(2023,12) dacc=Dict("MatA"=\>Dict(Date(2022,7)=\>751.19,Date(2023,1)=\>7.98), "Mat…

---

## [How to make a gantt plot with Plots.jl](https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 11\
**Last updated:** [August 14, 2023, 3:45pm UTC](https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165 "2023-08-14T15:45:25Z")

</div>

Hi, I would like to make a gantt plot in Plots.jl. I came across a few old posts concerning gantt plots, but no solution. Here is what I have so far: using StatsPlots using DataFrames df = DataFrame(label=\["A","B"\], …

---

## [How to get a zero-overhead view?](https://discourse.julialang.org/t/how-to-get-a-zero-overhead-view/102744)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 16\
**Last updated:** [August 14, 2023, 3:42pm UTC](https://discourse.julialang.org/t/how-to-get-a-zero-overhead-view/102744 "2023-08-14T15:42:40Z")

</div>

In C, I pass around pointers and lengths, constructing views with pointer arithmetic. This is annoying to debug, but quite performant. Is it possible to get equivalent performance with Julia views? I am okay with segfaul…

---

## [Could double summation be implemented without JuMP?](https://discourse.julialang.org/t/could-double-summation-be-implemented-without-jump/102785)

<div class="topic-metadata">

**Author:** [@MKY](https://discourse.julialang.org/u/MKY)\
**Replies:** 1\
**Last updated:** [August 14, 2023, 1:52pm UTC](https://discourse.julialang.org/t/could-double-summation-be-implemented-without-jump/102785 "2023-08-14T13:52:23Z")

</div>

Hello, I encounter a problem when trying to convert these(Python) to Julia: delta\_TRC = \[sum((i - TRC)\*\*2) for i in TRC\] return sum(delta\_TRC) I found that the syntax of sum function provided by JuMP is very si…

---

## [Julia kernel & Jupyter notebook in VSCode](https://discourse.julialang.org/t/julia-kernel-jupyter-notebook-in-vscode/102709)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 12\
**Last updated:** [August 14, 2023, 1:46pm UTC](https://discourse.julialang.org/t/julia-kernel-jupyter-notebook-in-vscode/102709 "2023-08-14T13:46:14Z")

</div>

I try to run a Jupyter notebook in VSCode (v.1.81.1) with Julia 1.9.2 installed. Problems: Julia 1.9.2 is not available when I try to choose kernel for the Jupyter notebook \[there is a Julia release channel, though – …

---

## [How do I define a new type of metadata for Symbolic parameters?](https://discourse.julialang.org/t/how-do-i-define-a-new-type-of-metadata-for-symbolic-parameters/102736)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [August 14, 2023, 1:41pm UTC](https://discourse.julialang.org/t/how-do-i-define-a-new-type-of-metadata-for-symbolic-parameters/102736 "2023-08-14T13:41:31Z")

</div>

I want to define a new type of metadata to note that a parameter is a diffusion parameter (governs a diffusion rate. How do I actually do this? I have tried to go through and copy what we do in Catalyst docs, but this g…

---

## [Save information in TimerOutput (TimerOutputs.jl) as a DataFrame](https://discourse.julialang.org/t/save-information-in-timeroutput-timeroutputs-jl-as-a-dataframe/102774)

<div class="topic-metadata">

**Author:** [@Martin](https://discourse.julialang.org/u/Martin)\
**Replies:** 2\
**Last updated:** [August 14, 2023, 1:25pm UTC](https://discourse.julialang.org/t/save-information-in-timeroutput-timeroutputs-jl-as-a-dataframe/102774 "2023-08-14T13:25:43Z")

</div>

Hi! At the moment I am comparing different (in this case machine learning) algorithms in a project, and I am interested in the running time and memory allocations. So I have been using the great package TimerOutputs.jl …

---

## [Speeding up a function](https://discourse.julialang.org/t/speeding-up-a-function/102703)

<div class="topic-metadata">

**Author:** [@ditfurth](https://discourse.julialang.org/u/ditfurth)\
**Replies:** 43\
**Last updated:** [August 14, 2023, 1:18pm UTC](https://discourse.julialang.org/t/speeding-up-a-function/102703 "2023-08-14T13:18:06Z")

</div>

Hi all, I have a function that needs some speeding up. I tried many things, here is the current state and a minimum working example # using BenchmarkTools, Random, Distributions, Base.Threads Random.seed!(123) market…

---

## [Transfer module definition to worker](https://discourse.julialang.org/t/transfer-module-definition-to-worker/102779)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 0\
**Last updated:** [August 14, 2023, 5:47am UTC](https://discourse.julialang.org/t/transfer-module-definition-to-worker/102779 "2023-08-14T05:47:38Z")

</div>

Is there a way to transfer a module definition to a worker without it being defined in a file or inside an @everywhere expression. For example: # Assume this happens in a context where it would be impractical to inser…

---

## [Type-unstable application of \`map\`](https://discourse.julialang.org/t/type-unstable-application-of-map/102771)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 4\
**Last updated:** [August 13, 2023, 8:17pm UTC](https://discourse.julialang.org/t/type-unstable-application-of-map/102771 "2023-08-13T20:17:34Z")

</div>

Consider the following (minimal?) example: julia\> struct A{N} A(::NTuple{N,Int}) where {N} = new{N}() end julia\> t = (1,2) (1, 2) julia\> T = typeof(t) Tuple{Int64, Int64} julia\> using Test julia\> @…

---

## [Accessing the category of a Char](https://discourse.julialang.org/t/accessing-the-category-of-a-char/102745)

<div class="topic-metadata">

**Author:** [@ultradian](https://discourse.julialang.org/u/ultradian)\
**Replies:** 4\
**Last updated:** [August 13, 2023, 11:05am UTC](https://discourse.julialang.org/t/accessing-the-category-of-a-char/102745 "2023-08-13T11:05:41Z")

</div>

I was playing around and just noticed that there is a category for every Char. For example: julia\> Char(‘a’) ‘a’: ASCII/Unicode U+0061 (category Ll: Letter, lowercase) julia\> Char(‘?’) ‘?’: ASCII/Unicode U+003F (cat…

---

## [Converting between interactive and non-interactive soft scope code](https://discourse.julialang.org/t/converting-between-interactive-and-non-interactive-soft-scope-code/102754)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 0\
**Last updated:** [August 12, 2023, 9:34pm UTC](https://discourse.julialang.org/t/converting-between-interactive-and-non-interactive-soft-scope-code/102754 "2023-08-12T21:34:50Z")

</div>

Never was a fan of some local scopes being made “soft”, meaning reassigning global variables without declarations in interactive contexts (REPL, notebooks) instead of making a local variable; for example, for \_ in 1 s=0 …

---

## [UndefVarError: \`ComponentArray\` not defined when using GPU in NeuralPDE](https://discourse.julialang.org/t/undefvarerror-componentarray-not-defined-when-using-gpu-in-neuralpde/102725)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 9\
**Last updated:** [August 13, 2023, 12:23am UTC](https://discourse.julialang.org/t/undefvarerror-componentarray-not-defined-when-using-gpu-in-neuralpde/102725 "2023-08-13T00:23:14Z")

</div>

I tried to run NeuralPDE with GPU by the tutorial code in NeuralPDE.jl as follows: using NeuralPDE, Lux, CUDA, Random using Optimization using OptimizationOptimisers import ModelingToolkit: Interval @parameters t x y @…

---

## [Generate sub-tuples in an efficient, type-stable way](https://discourse.julialang.org/t/generate-sub-tuples-in-an-efficient-type-stable-way/102750)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 2\
**Last updated:** [August 12, 2023, 5:56pm UTC](https://discourse.julialang.org/t/generate-sub-tuples-in-an-efficient-type-stable-way/102750 "2023-08-12T17:56:14Z")

</div>

Given a NTuple{N, T}, I’d like to generate the collection of all sub-tuples that can be obtained by removing one element from the original tuple. This collection of sub-tuples can be represented as an NTuple{N, NTuple{N-…

---

## [Cannot execute Julia 1.9.2 binary on NixOS](https://discourse.julialang.org/t/cannot-execute-julia-1-9-2-binary-on-nixos/102748)

<div class="topic-metadata">

**Author:** [@loonatick-src](https://discourse.julialang.org/u/loonatick-src)\
**Replies:** 2\
**Last updated:** [August 12, 2023, 5:30pm UTC](https://discourse.julialang.org/t/cannot-execute-julia-1-9-2-binary-on-nixos/102748 "2023-08-12T17:30:36Z")

</div>

(cross-posted from unix.stackexchange) This is most likely a NixOS-specific issue. I downloaded the Julia 1.9.2 (Linux, x86-64, glibc) prebuilt binary and tried to execute the binary, but I get the following error. bas…

---

## [Lighter alternatives to a dataframe when you just want to run a few queries on a vector of data structs](https://discourse.julialang.org/t/lighter-alternatives-to-a-dataframe-when-you-just-want-to-run-a-few-queries-on-a-vector-of-data-structs/102510)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 31\
**Last updated:** [August 12, 2023, 3:05pm UTC](https://discourse.julialang.org/t/lighter-alternatives-to-a-dataframe-when-you-just-want-to-run-a-few-queries-on-a-vector-of-data-structs/102510 "2023-08-12T15:05:50Z")

</div>

Lately, I have been running into a lot of tasks where I generate a big long vector of instances of some kind of data struct: julia\> struct Foo; a::Int; b::Int; end julia\> foos = \[Foo(rand(1:4), rand(1:4)) for \_ in 1:10…

---

## [Help to extend the model in Metalhead.jl](https://discourse.julialang.org/t/help-to-extend-the-model-in-metalhead-jl/102742)

<div class="topic-metadata">

**Author:** [@yeruo](https://discourse.julialang.org/u/yeruo)\
**Replies:** 5\
**Last updated:** [August 12, 2023, 10:17am UTC](https://discourse.julialang.org/t/help-to-extend-the-model-in-metalhead-jl/102742 "2023-08-12T10:17:48Z")

</div>

I implemented a self-supervised learning algorithm, MAE (Masked Auto Encoder), based on Flux.jl and Metalhead.jl, It seems to work, especially when propagating forward, but during gradient descent, Zygote alerted me that…

---

## [Reference counting and disposables](https://discourse.julialang.org/t/reference-counting-and-disposables/98875)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 4\
**Last updated:** [August 12, 2023, 8:56am UTC](https://discourse.julialang.org/t/reference-counting-and-disposables/98875 "2023-08-12T08:56:09Z")

</div>

In ResourcePools.jl/pooled\_abstract\_array.jl at feature/multi-threading · IHPSystems/ResourcePools.jl · GitHub, I have two concepts - in addition to pooled resources / pools of resources: Reference counted instances - …

---

## [Lux Neural ODE Example does not work with Metal](https://discourse.julialang.org/t/lux-neural-ode-example-does-not-work-with-metal/102740)

<div class="topic-metadata">

**Author:** [@George\_Stepaniants](https://discourse.julialang.org/u/George_Stepaniants)\
**Replies:** 0\
**Last updated:** [August 12, 2023, 3:06am UTC](https://discourse.julialang.org/t/lux-neural-ode-example-does-not-work-with-metal/102740 "2023-08-12T03:06:15Z")

</div>

I directly copied the Lux example for creating a neural ODE on MNIST: MNIST Classification using NeuralODE - Lux.jl and simply replaced CUDA with Metal to use my Mac M1 GPU. However, just from this single change the cod…

---

## [Read datetime with timezone offset from csv](https://discourse.julialang.org/t/read-datetime-with-timezone-offset-from-csv/102738)

<div class="topic-metadata">

**Author:** [@vtomar](https://discourse.julialang.org/u/vtomar)\
**Replies:** 1\
**Last updated:** [August 11, 2023, 11:46pm UTC](https://discourse.julialang.org/t/read-datetime-with-timezone-offset-from-csv/102738 "2023-08-11T23:46:13Z")

</div>

I have a csv file that contains datetime column where datetime contains timezone offset. for example: 2019-01-11 17:35:00+00:00 How do I correctly specify the datetime format. I am currently specifying the format below…

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

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