# General Usage

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

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

**Page:** 621

---

## [Can NamedDims.jl make use of sparse arrays?](https://discourse.julialang.org/t/can-nameddims-jl-make-use-of-sparse-arrays/55043)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 2\
**Last updated:** [March 31, 2021, 2:54pm UTC](https://discourse.julialang.org/t/can-nameddims-jl-make-use-of-sparse-arrays/55043 "2021-03-31T14:54:30Z")

</div>

Can NamedDims.jl make use of sparse arrays? Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Di…

---

## [Are there any libraries for discrete probability tables in order to do these type](https://discourse.julialang.org/t/are-there-any-libraries-for-discrete-probability-tables-in-order-to-do-these-type/54990)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 2\
**Last updated:** [March 31, 2021, 2:53pm UTC](https://discourse.julialang.org/t/are-there-any-libraries-for-discrete-probability-tables-in-order-to-do-these-type/54990 "2021-03-31T14:53:44Z")

</div>

Are there any libraries for discrete probability tables in order to do these type of operations directly (see images)? I’m looking for having discrete probability tables with these operations defined on them. I also wan…

---

## [Performance of computing the diagonal of V' \* A \*V](https://discourse.julialang.org/t/performance-of-computing-the-diagonal-of-v-a-v/58288)

<div class="topic-metadata">

**Author:** [@migarstka](https://discourse.julialang.org/u/migarstka)\
**Replies:** 10\
**Last updated:** [March 31, 2021, 1:22pm UTC](https://discourse.julialang.org/t/performance-of-computing-the-diagonal-of-v-a-v/58288 "2021-03-31T13:22:55Z")

</div>

I want to compute the diagonal elements of X = V^\\top A V where V is an orthogonal matrix A is a symmetric matrix I noticed that it is much faster to just compute X and then extract the diagonal elements than compu…

---

## [How do i make a square lattice of (2n+1) x (2n+1)?](https://discourse.julialang.org/t/how-do-i-make-a-square-lattice-of-2n-1-x-2n-1/58158)

<div class="topic-metadata">

**Author:** [@CashMoneyyyy](https://discourse.julialang.org/u/CashMoneyyyy)\
**Replies:** 11\
**Last updated:** [March 31, 2021, 1:19pm UTC](https://discourse.julialang.org/t/how-do-i-make-a-square-lattice-of-2n-1-x-2n-1/58158 "2021-03-31T13:19:52Z")

</div>

I need to define a square lattice of size (2n+1) x (2n+1) and assign each cell as zero. Could anyone help me out on how to do this?

---

## [Selectively enable debug level logging with a custom \`global\_logger\`](https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286)

<div class="topic-metadata">

**Author:** [@dm3](https://discourse.julialang.org/u/dm3)\
**Replies:** 1\
**Last updated:** [March 31, 2021, 12:24pm UTC](https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286 "2021-03-31T12:24:24Z")

</div>

Hello! I’m at a loss on how to selectively enable debug logging when overriding a global logger. If I override the global\_logger like this: ConsoleLogger(stdout, Logging.Info) |\> global\_logger then setting ENV\["JULIA\_D…

---

## [Iterating through types of a Union in a type-stable manner](https://discourse.julialang.org/t/iterating-through-types-of-a-union-in-a-type-stable-manner/58285)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 2\
**Last updated:** [March 31, 2021, 12:03pm UTC](https://discourse.julialang.org/t/iterating-through-types-of-a-union-in-a-type-stable-manner/58285 "2021-03-31T12:03:29Z")

</div>

Hi, I have the following: union\_types(x::Union) = union\_types(x.a, x.b) union\_types(a::Union, b::Type) = (union\_types(a)..., b) union\_types(a::Type, b::Type) = (a, b) union\_types(x::Type) = (x,) # For completeness unio…

---

## [Dispatch on precice Union instance in place of subtyping supertype of Union](https://discourse.julialang.org/t/dispatch-on-precice-union-instance-in-place-of-subtyping-supertype-of-union/58117)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 7\
**Last updated:** [March 31, 2021, 10:02am UTC](https://discourse.julialang.org/t/dispatch-on-precice-union-instance-in-place-of-subtyping-supertype-of-union/58117 "2021-03-31T10:02:33Z")

</div>

This is a bit tricky I feel, but I didn’t really found out how to separate the two cases. I have an abstract type AbstractAgent. I have a model type which is parameterized on subtypes of my abstract type, see the follow…

---

## [Implementing option to profile a script as environment variable or command line argument](https://discourse.julialang.org/t/implementing-option-to-profile-a-script-as-environment-variable-or-command-line-argument/58189)

<div class="topic-metadata">

**Author:** [@luke](https://discourse.julialang.org/u/luke)\
**Replies:** 4\
**Last updated:** [March 31, 2021, 12:20am UTC](https://discourse.julialang.org/t/implementing-option-to-profile-a-script-as-environment-variable-or-command-line-argument/58189 "2021-03-31T00:20:12Z")

</div>

This is a bit of a stylistic “what’s the most elegant way to do this?” question than a functionality question. Basically, let’s say we have a script that runs some computation and saves some outputs for us, and we’re cur…

---

## [Pkg.add updates other packages too?](https://discourse.julialang.org/t/pkg-add-updates-other-packages-too/58165)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 2\
**Last updated:** [March 27, 2021, 8:38pm UTC](https://discourse.julialang.org/t/pkg-add-updates-other-packages-too/58165 "2021-03-27T20:38:27Z")

</div>

I installed Julia 1.6 I installed the latest MLJ 0.16 I installed NaiveBayes.jl but got downgraded to MLJ 0.15.2 without my consent! Is this non-consentual downgrading intended? If this is the wrong place please redire…

---

## [Convert dictionary of dataframes into single dataframe](https://discourse.julialang.org/t/convert-dictionary-of-dataframes-into-single-dataframe/58255)

<div class="topic-metadata">

**Author:** [@waforbes](https://discourse.julialang.org/u/waforbes)\
**Replies:** 5\
**Last updated:** [March 30, 2021, 8:46pm UTC](https://discourse.julialang.org/t/convert-dictionary-of-dataframes-into-single-dataframe/58255 "2021-03-30T20:46:57Z")

</div>

I have a dictionary of dataframes that I want to combine into a single dataframe.

---

## [Implement iterator over subsets of array](https://discourse.julialang.org/t/implement-iterator-over-subsets-of-array/58251)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 9\
**Last updated:** [March 30, 2021, 7:59pm UTC](https://discourse.julialang.org/t/implement-iterator-over-subsets-of-array/58251 "2021-03-30T19:59:16Z")

</div>

Suppose I have an array like x = \[ 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4 \] I want to loop over the sets of sequences of common numbers, using a syntax like: for set in eachset(x) ... end Where eachset(x) should behav…

---

## [Did Julia 1.6 introduced a regression for regex properties?](https://discourse.julialang.org/t/did-julia-1-6-introduced-a-regression-for-regex-properties/58076)

<div class="topic-metadata">

**Author:** [@D\_A](https://discourse.julialang.org/u/D_A)\
**Replies:** 2\
**Last updated:** [March 30, 2021, 7:08pm UTC](https://discourse.julialang.org/t/did-julia-1-6-introduced-a-regression-for-regex-properties/58076 "2021-03-30T19:08:12Z")

</div>

Hello. It seems the latest Julia release (nice job, by the way!) introduced a strange behaviour for regex properties, especially with scripts… text = "aa bb" text |\> collect # 'a': ASCII/Unicode U+0061 (category Ll: Le…

---

## [Creating dataframe with column name that is a variable](https://discourse.julialang.org/t/creating-dataframe-with-column-name-that-is-a-variable/58248)

<div class="topic-metadata">

**Author:** [@waforbes](https://discourse.julialang.org/u/waforbes)\
**Replies:** 7\
**Last updated:** [March 30, 2021, 5:23pm UTC](https://discourse.julialang.org/t/creating-dataframe-with-column-name-that-is-a-variable/58248 "2021-03-30T17:23:31Z")

</div>

All of the other columns are correct, i.e. I want “StartPoint” to be the name of the column and it has the data in the variable start\_space. Below, param is a string variable. How do I tell it that I want the column name…

---

## [How to repleace some chars in a HTTP --\> CSV --\> DataFrame workflow?](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 4\
**Last updated:** [March 30, 2021, 4:45pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232 "2021-03-30T16:45:36Z")

</div>

I am trying to pass a (small) CSV file to DataFrame without saving it to disk, but I need first to convert the tabs in spaces, as it is a bit “dirty”. I have tried this but it doesn’t work: urlData = "https://archive.i…

---

## [CUDA.jl tutorial code kernel slower than broadcast](https://discourse.julialang.org/t/cuda-jl-tutorial-code-kernel-slower-than-broadcast/58242)

<div class="topic-metadata">

**Author:** [@Satvik](https://discourse.julialang.org/u/Satvik)\
**Replies:** 4\
**Last updated:** [March 30, 2021, 4:05pm UTC](https://discourse.julialang.org/t/cuda-jl-tutorial-code-kernel-slower-than-broadcast/58242 "2021-03-30T16:05:06Z")

</div>

Hi, The CUDA.jl tutorial has broadcasted addition, and then a series of steps to write a kernel that’s supposed to be about as fast. But on my machine, the kernel is about 10x slower, and I’d like to understand why. He…

---

## [Cannot take gradient of a function involves \`eachrow\` with Zygote?](https://discourse.julialang.org/t/cannot-take-gradient-of-a-function-involves-eachrow-with-zygote/58098)

<div class="topic-metadata">

**Author:** [@qft](https://discourse.julialang.org/u/qft)\
**Replies:** 3\
**Last updated:** [March 30, 2021, 3:48pm UTC](https://discourse.julialang.org/t/cannot-take-gradient-of-a-function-involves-eachrow-with-zygote/58098 "2021-03-30T15:48:04Z")

</div>

The following code using Zygote gradient(x -\> sum(map(sum, eachcol(x))), rand(3, 4)) gives the error message ERROR: Need an adjoint for constructor Base.Generator{Base.OneTo{Int64}, Base.var"#193#194"{Matrix{Float64}…

---

## [Read .mat file from base64](https://discourse.julialang.org/t/read-mat-file-from-base64/58217)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 1\
**Last updated:** [March 30, 2021, 1:35pm UTC](https://discourse.julialang.org/t/read-mat-file-from-base64/58217 "2021-03-30T13:35:36Z")

</div>

Suppose I have the following based64 encoded .mat file: using MAT using Base64 mat\_enc = open(base64encode, "01.mat") mat\_dec = base64decode(mat\_enc) open("my\_01.mat", "w") do f write(f, mat\_dec) end data = matread("m…

---

## [Addprocs() does not work](https://discourse.julialang.org/t/addprocs-does-not-work/58211)

<div class="topic-metadata">

**Author:** [@mariok90](https://discourse.julialang.org/u/mariok90)\
**Replies:** 6\
**Last updated:** [March 30, 2021, 1:25pm UTC](https://discourse.julialang.org/t/addprocs-does-not-work/58211 "2021-03-30T13:25:37Z")

</div>

When I use addprocs() julia crashes with that error message: julia\> using Distributed julia\> workers() 1-element Array{Int64,1}: 1 julia\> addprocs() 16-element Array{Int64,1}: 2 3 4 5 6 7 8 9 10 11 …

---

## [GMSH Mesh Expert to Julia using koehlerson/gmsh.jl](https://discourse.julialang.org/t/gmsh-mesh-expert-to-julia-using-koehlerson-gmsh-jl/58169)

<div class="topic-metadata">

**Author:** [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Replies:** 4\
**Last updated:** [March 30, 2021, 11:03am UTC](https://discourse.julialang.org/t/gmsh-mesh-expert-to-julia-using-koehlerson-gmsh-jl/58169 "2021-03-30T11:03:03Z")

</div>

Short Version of Query: Consider a unit square (2D) domain and a triangular mesh on this geometry. I would like to perform a loop over all the elements in the mesh, compute the area of each triangle and verify that the …

---

## [Run code non-interactively with a Julia server](https://discourse.julialang.org/t/run-code-non-interactively-with-a-julia-server/58208)

<div class="topic-metadata">

**Author:** [@Chen](https://discourse.julialang.org/u/Chen)\
**Replies:** 2\
**Last updated:** [March 30, 2021, 9:37am UTC](https://discourse.julialang.org/t/run-code-non-interactively-with-a-julia-server/58208 "2021-03-30T09:37:48Z")

</div>

I read from Getting Started · The Julia Language that I can run a Julia script non-interactively: $ julia script.jl arg1 arg2... However, for certain scripts it will take time because Julia will need to compile it firs…

---

## [Why is plotting with GR faster when using GR\_jll and \`@ccall\` directly](https://discourse.julialang.org/t/why-is-plotting-with-gr-faster-when-using-gr-jll-and-ccall-directly/58199)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 9\
**Last updated:** [March 30, 2021, 6:57am UTC](https://discourse.julialang.org/t/why-is-plotting-with-gr-faster-when-using-gr-jll-and-ccall-directly/58199 "2021-03-30T06:57:01Z")

</div>

Why is plotting with GR faster when using GR\_jll and @ccall directly? @jheinen using GR\_jll \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | Type "?"…

---

## [VS Code semicolon at the end of commented line](https://discourse.julialang.org/t/vs-code-semicolon-at-the-end-of-commented-line/58195)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 3\
**Last updated:** [March 30, 2021, 5:50am UTC](https://discourse.julialang.org/t/vs-code-semicolon-at-the-end-of-commented-line/58195 "2021-03-30T05:50:54Z")

</div>

Minor thing but nevertheless surprising at first sight: is the following a bug in Julia VS Code extension or a feature? # VS Code 1.54.3 Win10; Julia extension 1.1.38 b = 1 # CTRL + ENTER shows value in terminal # …

---

## [Printing an array without element type](https://discourse.julialang.org/t/printing-an-array-without-element-type/6731)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 3\
**Last updated:** [March 29, 2021, 10:20pm UTC](https://discourse.julialang.org/t/printing-an-array-without-element-type/6731 "2021-03-29T22:20:15Z")

</div>

For example, when I print an array of complex numbers, the result shows the element type as “Complex{Float64}”: julia\> c = rand(Complex128,3); println("c = $c") c = Complex{Float64}\[0.77556+0.100567im, 0.482976+0.657349…

---

## [Parsing Nested JSON into DataFrame using JSONTable](https://discourse.julialang.org/t/parsing-nested-json-into-dataframe-using-jsontable/58127)

<div class="topic-metadata">

**Author:** [@clibassi](https://discourse.julialang.org/u/clibassi)\
**Replies:** 1\
**Last updated:** [March 29, 2021, 10:00pm UTC](https://discourse.julialang.org/t/parsing-nested-json-into-dataframe-using-jsontable/58127 "2021-03-29T22:00:31Z")

</div>

I’m trying to parse academic publication data from Open Academic Graph, which stores the data in JSON format, but am running into an issue with parsing the below sample JSON they provide on the website because it is nest…

---

## [Error installing artifact dependency](https://discourse.julialang.org/t/error-installing-artifact-dependency/57961)

<div class="topic-metadata">

**Author:** [@bencherian](https://discourse.julialang.org/u/bencherian)\
**Replies:** 3\
**Last updated:** [March 29, 2021, 9:52pm UTC](https://discourse.julialang.org/t/error-installing-artifact-dependency/57961 "2021-03-29T21:52:01Z")

</div>

I just installed Julia 1.6.0 and was installing a basic set of packages when I got the error below when trying to install Plots.jl (@v1.6) pkg\> add Plots Resolving package versions... Downloaded artifact: XML2 Do…

---

## [Speed Up For Loop for Bounds Checking](https://discourse.julialang.org/t/speed-up-for-loop-for-bounds-checking/58188)

<div class="topic-metadata">

**Author:** [@PJoynt](https://discourse.julialang.org/u/PJoynt)\
**Replies:** 5\
**Last updated:** [March 29, 2021, 9:14pm UTC](https://discourse.julialang.org/t/speed-up-for-loop-for-bounds-checking/58188 "2021-03-29T21:14:31Z")

</div>

Hi, I was wondering if I could get some feedback on how I can increase the performance of this section of code, I am relatively new to Julia and I am not to sure if there is a better way to do this: x = \[-88.58, -86.31,…

---

## [PSA: Reasoning about scope rules and multithreading](https://discourse.julialang.org/t/psa-reasoning-about-scope-rules-and-multithreading/56967)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 3\
**Last updated:** [March 29, 2021, 8:58pm UTC](https://discourse.julialang.org/t/psa-reasoning-about-scope-rules-and-multithreading/56967 "2021-03-29T20:58:57Z")

</div>

Perhaps this has been discussed before and I missed it, but during my first experimentation with multithreading, I suddenly realized that Julia’s scoping rules in loops, which a number of people find confusing (including…

---

## [Error running finalizers](https://discourse.julialang.org/t/error-running-finalizers/39247)

<div class="topic-metadata">

**Author:** [@samuel\_okon](https://discourse.julialang.org/u/samuel_okon)\
**Replies:** 2\
**Last updated:** [March 29, 2021, 7:14pm UTC](https://discourse.julialang.org/t/error-running-finalizers/39247 "2021-03-29T19:14:54Z")

</div>

I sometimes get this error when running multi-threaded code (Basically nested @spawn calls) error in running finalizer: ErrorException("concurrency violation detected") . Does anyone know what could cause this?. The funn…

---

## [Confusion between Char and String](https://discourse.julialang.org/t/confusion-between-char-and-string/58179)

<div class="topic-metadata">

**Author:** [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Replies:** 2\
**Last updated:** [March 29, 2021, 5:57pm UTC](https://discourse.julialang.org/t/confusion-between-char-and-string/58179 "2021-03-29T17:57:02Z")

</div>

In the picture below, everything is suppose to be strings, but an error “Cannot convert Char to String” occurred. Maybe this is a bug, or just me not doing it correctly, not sure.

---

## [Crazy allocations using CartesianIndices](https://discourse.julialang.org/t/crazy-allocations-using-cartesianindices/42262)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 14\
**Last updated:** [March 29, 2021, 12:44pm UTC](https://discourse.julialang.org/t/crazy-allocations-using-cartesianindices/42262 "2021-03-29T12:44:33Z")

</div>

I have been switching over a 2D flux computation method to use CartesianIndices so it will work for arrays of any dimension, ala Multidimensional algorithms and iteration Unfortunately, I’ve been running into a bunch of…

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

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