# General Usage

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

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

**Page:** 288

---

## [Making a view of a combination of array indexes and scalars, creating an array to send to a function](https://discourse.julialang.org/t/making-a-view-of-a-combination-of-array-indexes-and-scalars-creating-an-array-to-send-to-a-function/99332)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 7\
**Last updated:** [May 25, 2023, 3:24pm UTC](https://discourse.julialang.org/t/making-a-view-of-a-combination-of-array-indexes-and-scalars-creating-an-array-to-send-to-a-function/99332 "2023-05-25T15:24:47Z")

</div>

I have a combination of scalar values, and values stored in vectors. Is there a good way to create a view of these and send to other functions, rather than allocating it all to a new array? I am performance de-bugging a…

---

## [Using Tuples within ModelingToolkit.jl?](https://discourse.julialang.org/t/using-tuples-within-modelingtoolkit-jl/99350)

<div class="topic-metadata">

**Author:** [@MarkIlg](https://discourse.julialang.org/u/MarkIlg)\
**Replies:** 1\
**Last updated:** [May 25, 2023, 1:01pm UTC](https://discourse.julialang.org/t/using-tuples-within-modelingtoolkit-jl/99350 "2023-05-25T13:01:16Z")

</div>

Trying to utlized MTK on a larger simulation and having trouble with functions that return tuples that are a function of state. For example: function foo(x) return 1.0,2.0 end @register\_symbolic foo(x) function pl…

---

## [The most efficient way to calculate the pairwise correlation between rows of a large Matrix{Float64}](https://discourse.julialang.org/t/the-most-efficient-way-to-calculate-the-pairwise-correlation-between-rows-of-a-large-matrix-float64/99313)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 10\
**Last updated:** [May 25, 2023, 11:02am UTC](https://discourse.julialang.org/t/the-most-efficient-way-to-calculate-the-pairwise-correlation-between-rows-of-a-large-matrix-float64/99313 "2023-05-25T11:02:54Z")

</div>

I wonder the most efficient way to calculate the pairwise correlation between rows of a Matrix{Float64} with a large number of rows and columns. I know “large” is subjective. Suppose the large is (5000, 50000) (meaning 5…

---

## [Why can Channels not be used by threads?](https://discourse.julialang.org/t/why-can-channels-not-be-used-by-threads/99353)

<div class="topic-metadata">

**Author:** [@hsgg](https://discourse.julialang.org/u/hsgg)\
**Replies:** 8\
**Last updated:** [May 25, 2023, 3:59am UTC](https://discourse.julialang.org/t/why-can-channels-not-be-used-by-threads/99353 "2023-05-25T03:59:51Z")

</div>

I am using Channels to synchronize and distribute workloads between threads (and it is working really well). However, the documentation about @threads states that the assumptions that go into the threading model mean th…

---

## [Extending @formula syntax is difficult to understand](https://discourse.julialang.org/t/extending-formula-syntax-is-difficult-to-understand/99326)

<div class="topic-metadata">

**Author:** [@xuanquansheng](https://discourse.julialang.org/u/xuanquansheng)\
**Replies:** 3\
**Last updated:** [May 25, 2023, 2:27am UTC](https://discourse.julialang.org/t/extending-formula-syntax-is-difficult-to-understand/99326 "2023-05-25T02:27:57Z")

</div>

Extending @formula syntax in StatsModels.jl is difficult to understand. I read the examples of ploy in the official documentation, but I feel that the comments are not detailed enough, and I still don’t quite understand…

---

## [How to intrepret the results from the 'cdf()\` and \`quantile()\` function?](https://discourse.julialang.org/t/how-to-intrepret-the-results-from-the-cdf-and-quantile-function/99354)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 1\
**Last updated:** [May 24, 2023, 11:12pm UTC](https://discourse.julialang.org/t/how-to-intrepret-the-results-from-the-cdf-and-quantile-function/99354 "2023-05-24T23:12:55Z")

</div>

Hey, folks I’d like some help understanding the cdf and quantile functions. Let x \\in \\mathbb{R}^n be a data vector. using Random Random.seed!(12345) x = rand(Uniform(100, 500), 10000) Now, I want to calculate the c…

---

## [Continuation passing style and compile-time computation](https://discourse.julialang.org/t/continuation-passing-style-and-compile-time-computation/98769)

<div class="topic-metadata">

**Author:** [@olynch](https://discourse.julialang.org/u/olynch)\
**Replies:** 4\
**Last updated:** [May 24, 2023, 8:14pm UTC](https://discourse.julialang.org/t/continuation-passing-style-and-compile-time-computation/98769 "2023-05-24T20:14:56Z")

</div>

n AlgebraicJulia, we have a repeated problem that shows up in a number of places, where we want to pass values computed by one macro into another macro. One classic example of this sort of problem is that we often want …

---

## [Julia (Juliaup from Windows store) flagged as virus by Trend micro Apex One](https://discourse.julialang.org/t/julia-juliaup-from-windows-store-flagged-as-virus-by-trend-micro-apex-one/99331)

<div class="topic-metadata">

**Author:** [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Replies:** 2\
**Last updated:** [May 24, 2023, 2:05pm UTC](https://discourse.julialang.org/t/julia-juliaup-from-windows-store-flagged-as-virus-by-trend-micro-apex-one/99331 "2023-05-24T14:05:03Z")

</div>

On my pro laptop, my lab installed the antivirus Trend micro Apex One. I have been using it with Julia (downloaded with Juliaup from Windows store) for months. Suddenly todady, while I was using with VSCode LiveServer.…

---

## [VS Code error: Varaible has been assigned but not used](https://discourse.julialang.org/t/vs-code-error-varaible-has-been-assigned-but-not-used/99324)

<div class="topic-metadata">

**Author:** [@dgagnon](https://discourse.julialang.org/u/dgagnon)\
**Replies:** 10\
**Last updated:** [May 24, 2023, 1:28pm UTC](https://discourse.julialang.org/t/vs-code-error-varaible-has-been-assigned-but-not-used/99324 "2023-05-24T13:28:31Z")

</div>

Hello I am puzzled by an error message in VS code. I have the folloing function below and VS Code is telling me that at line 11, where I compute the likelihood, that VARIABLE HAS BEEN ASSIGNED BUT NOT USED. The functio…

---

## [How to smooth zig-zag?](https://discourse.julialang.org/t/how-to-smooth-zig-zag/98914)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 3\
**Last updated:** [May 24, 2023, 10:13am UTC](https://discourse.julialang.org/t/how-to-smooth-zig-zag/98914 "2023-05-24T10:13:52Z")

</div>

How to smooth a zig-zag-line with only a few points? I have read the following topics here in this forum: smoothing-interpolation-for-tachometer-data smoothing-data-with-dates But I am still struggling with my sort o…

---

## [KernelAbstractions on CPU. Why so slow?](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 8\
**Last updated:** [May 24, 2023, 9:40am UTC](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272 "2023-05-24T09:40:00Z")

</div>

In the following code, launched with a single thread, KernelAbstractions’ function is almost twice slower than a simple broadcasting. Any ideas why? using BenchmarkTools using KernelAbstractions @kernel function mulcab…

---

## [Problem reading parquet file in Julia 1.9.0](https://discourse.julialang.org/t/problem-reading-parquet-file-in-julia-1-9-0/99314)

<div class="topic-metadata">

**Author:** [@MiquellaXMalenia](https://discourse.julialang.org/u/MiquellaXMalenia)\
**Replies:** 0\
**Last updated:** [May 24, 2023, 8:47am UTC](https://discourse.julialang.org/t/problem-reading-parquet-file-in-julia-1-9-0/99314 "2023-05-24T08:47:59Z")

</div>

Hello, Is anyone else experiencing problems reading parquet files in Julia 1.9.0? I was checking how my code performed when upgrading my Julia version from 1.8.4 to 1.9.0, and noticed the first run being extremely slow.…

---

## [Using @logmsg with begin/end blocks](https://discourse.julialang.org/t/using-logmsg-with-begin-end-blocks/99290)

<div class="topic-metadata">

**Author:** [@florian](https://discourse.julialang.org/u/florian)\
**Replies:** 3\
**Last updated:** [May 24, 2023, 7:10am UTC](https://discourse.julialang.org/t/using-logmsg-with-begin-end-blocks/99290 "2023-05-24T07:10:45Z")

</div>

Is it somehow possible to do this: @debug "Results of my calculations: " A=1:100 B=(1:100).\*10 In block form, meaning something like this: @debug begin ## Do some stuff: A = 1:100 B = A .\* 10 ## C…

---

## [Inconsistent behaviour using Zygote.Buffer](https://discourse.julialang.org/t/inconsistent-behaviour-using-zygote-buffer/99139)

<div class="topic-metadata">

**Author:** [@keithjlee](https://discourse.julialang.org/u/keithjlee)\
**Replies:** 2\
**Last updated:** [May 23, 2023, 11:45pm UTC](https://discourse.julialang.org/t/inconsistent-behaviour-using-zygote-buffer/99139 "2023-05-23T23:45:22Z")

</div>

I’m working on making a structural analysis code base work smoothly with Automatic Differentiation, specifically Zygote for its generally friendly interface. In short, a major performance bottleneck is the assembly of th…

---

## [Scripting like a Julian](https://discourse.julialang.org/t/scripting-like-a-julian/50707)

<div class="topic-metadata">

**Author:** [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Replies:** 7\
**Last updated:** [May 23, 2023, 11:13pm UTC](https://discourse.julialang.org/t/scripting-like-a-julian/50707 "2023-05-23T23:13:17Z")

</div>

I’ve been talking to a few people and since this topic comes up regularly, I thought I’d write up my workflow for writing “scripts”. I don’t have a standard blog or place to put this, so I thought I’d put it here and tag…

---

## [Issues when using multiple threads through Threads.@threads](https://discourse.julialang.org/t/issues-when-using-multiple-threads-through-threads-threads/98758)

<div class="topic-metadata">

**Author:** [@jianqixi](https://discourse.julialang.org/u/jianqixi)\
**Replies:** 6\
**Last updated:** [May 23, 2023, 9:17pm UTC](https://discourse.julialang.org/t/issues-when-using-multiple-threads-through-threads-threads/98758 "2023-05-23T21:17:32Z")

</div>

I am trying to use multiple threads to speed up my code. But it is very confusing when I use the Threads.@threads in my code. Here is one simple example of the code: Threads.@threads for i in 1:3 hits = Set{Int}() b =…

---

## [Why is typeof not type inferable in this case?](https://discourse.julialang.org/t/why-is-typeof-not-type-inferable-in-this-case/99297)

<div class="topic-metadata">

**Author:** [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Replies:** 2\
**Last updated:** [May 23, 2023, 7:13pm UTC](https://discourse.julialang.org/t/why-is-typeof-not-type-inferable-in-this-case/99297 "2023-05-23T19:13:43Z")

</div>

I’m messing around with ForwardDiff, trying to write some type stable code, and have found an instance where typeof does not properly infer the type. I’m a bit stuck as to what to try here! I think this particular funct…

---

## [From Python (or other) "numbers" (days) to Julia's Dates type](https://discourse.julialang.org/t/from-python-or-other-numbers-days-to-julias-dates-type/99269)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 3\
**Last updated:** [May 23, 2023, 6:12pm UTC](https://discourse.julialang.org/t/from-python-or-other-numbers-days-to-julias-dates-type/99269 "2023-05-23T18:12:26Z")

</div>

Hi all. A pythonean colleague just send this julian a file full of “python numbers (days)”. I need to change this to julia Dates to plot his data next to mine. The data looks like this: Date in python Ydat…

---

## [Parallel for nested loop with inner loop first, and then outer loop](https://discourse.julialang.org/t/parallel-for-nested-loop-with-inner-loop-first-and-then-outer-loop/99254)

<div class="topic-metadata">

**Author:** [@jianqixi](https://discourse.julialang.org/u/jianqixi)\
**Replies:** 2\
**Last updated:** [May 23, 2023, 4:04pm UTC](https://discourse.julialang.org/t/parallel-for-nested-loop-with-inner-loop-first-and-then-outer-loop/99254 "2023-05-23T16:04:36Z")

</div>

Hi, I am wondering how could I use @spawn to parallelize the nested loops, and to run the inner loop in parallel first, and then run the outer loop in parallel after that. Thanks

---

## [Workflow Example for creating a new Julia project](https://discourse.julialang.org/t/workflow-example-for-creating-a-new-julia-project/99286)

<div class="topic-metadata">

**Author:** [@johnh](https://discourse.julialang.org/u/johnh)\
**Replies:** 2\
**Last updated:** [May 23, 2023, 3:06pm UTC](https://discourse.julialang.org/t/workflow-example-for-creating-a-new-julia-project/99286 "2023-05-23T15:06:48Z")

</div>

Back along, someone made a reply to one of my posts. This contained a most excellent step by step guide to creating a new Julia project, with how to create a fresh project and manage packages. If anyone remembers this p…

---

## [HOF for a function not throwing an error](https://discourse.julialang.org/t/hof-for-a-function-not-throwing-an-error/99277)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [May 23, 2023, 2:24pm UTC](https://discourse.julialang.org/t/hof-for-a-function-not-throwing-an-error/99277 "2023-05-23T14:24:56Z")

</div>

Does this have a name, or does it exist in a package? function throws\_no\_errors(f, args...) try f(args...) true catch false end end If not, suggestions for both are welcome.

---

## [pre-allocating array is slow](https://discourse.julialang.org/t/pre-allocating-array-is-slow/99233)

<div class="topic-metadata">

**Author:** [@dazhwu](https://discourse.julialang.org/u/dazhwu)\
**Replies:** 8\
**Last updated:** [May 23, 2023, 2:23pm UTC](https://discourse.julialang.org/t/pre-allocating-array-is-slow/99233 "2023-05-23T14:23:31Z")

</div>

I tried three ways of calculating the first difference of a series. To my disappointment, the 3rd method is 100 times as slow as the other two. So, in such a case, using the first two methods are better? using Benchmark…

---

## [Colorway / repeat standard colors in subplots](https://discourse.julialang.org/t/colorway-repeat-standard-colors-in-subplots/99282)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 0\
**Last updated:** [May 23, 2023, 1:52pm UTC](https://discourse.julialang.org/t/colorway-repeat-standard-colors-in-subplots/99282 "2023-05-23T13:52:27Z")

</div>

I have two subplots and would like to repeat the same color sequence inside these subplots. One way is to define upfront my own list of colors, another way is to get access to the standard colors of the current color sch…

---

## [Type inference problem with nested keyword calls](https://discourse.julialang.org/t/type-inference-problem-with-nested-keyword-calls/99101)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 10\
**Last updated:** [May 23, 2023, 1:16pm UTC](https://discourse.julialang.org/t/type-inference-problem-with-nested-keyword-calls/99101 "2023-05-23T13:16:23Z")

</div>

In some code for a structural model, I use keywords to pass around arguments, to avoid mistakes. But it causes type inference to fail. Below is an MWE (sorry, could not make it any smaller, I tried many ways but then the…

---

## [Which files or subdirectories in \`~/.julia/\` can I delete?](https://discourse.julialang.org/t/which-files-or-subdirectories-in-julia-can-i-delete/62230)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 21\
**Last updated:** [May 23, 2023, 12:34pm UTC](https://discourse.julialang.org/t/which-files-or-subdirectories-in-julia-can-i-delete/62230 "2023-05-23T12:34:24Z")

</div>

I am running Julia 1.5.4 on a HPC cluster, which has a strict 200,000 file count per user. ~/.julia consumes \>75% of this quota: $ du -a | cut -d/ -f2 | sort | uniq -c | sort -nr 153692 .julia 19159 .conda 10007 N…

---

## [Findfirst alternative for Set](https://discourse.julialang.org/t/findfirst-alternative-for-set/99271)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 6\
**Last updated:** [May 23, 2023, 12:07pm UTC](https://discourse.julialang.org/t/findfirst-alternative-for-set/99271 "2023-05-23T12:07:36Z")

</div>

Hi there, I am wondering whether there is something similar to findfirst which does not return the index, but the matching object itself. This would be useful to work with Sets julia\> findfirst(x-\>x==1,Set(\[1,2,3\])) E…

---

## [I Want to Plot Second Derivative of Inverse Secant Function with SymPy](https://discourse.julialang.org/t/i-want-to-plot-second-derivative-of-inverse-secant-function-with-sympy/99179)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 6\
**Last updated:** [May 23, 2023, 5:47am UTC](https://discourse.julialang.org/t/i-want-to-plot-second-derivative-of-inverse-secant-function-with-sympy/99179 "2023-05-23T05:47:56Z")

</div>

Hi all, I have the formula for the first derivative for secant inverse: D\_{x} \\sec^{-1} \\ x = \\frac{1}{|x| \\sqrt{x^{2}-1}} with |x| \> 1 I can manually find the second derivative (the second is very complex). Then c…

---

## [\[Blog Post\] A Fun Exploration of Perfect, Abundant, and Deficient Numbers](https://discourse.julialang.org/t/blog-post-a-fun-exploration-of-perfect-abundant-and-deficient-numbers/99168)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 5\
**Last updated:** [May 23, 2023, 3:17am UTC](https://discourse.julialang.org/t/blog-post-a-fun-exploration-of-perfect-abundant-and-deficient-numbers/99168 "2023-05-23T03:17:58Z")

</div>

Hey folks, I recently wrote a blog post with a very small computational treatment of exploring abundant, deficient, and perfect numbers (the latter only briefly) alongside aliquot sequences. This was my first foray into…

---

## [Printf with variable format string](https://discourse.julialang.org/t/printf-with-variable-format-string/3805)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 14\
**Last updated:** [May 22, 2023, 9:04pm UTC](https://discourse.julialang.org/t/printf-with-variable-format-string/3805 "2023-05-22T21:04:55Z")

</div>

Due to @printf being a macro, it does not accept a format string that has been passed as a variable. myvec = randn(4) n = length(myvec) outstring = "Beginning of string with some numbers: " for i = 1:n outstring = o…

---

## [MLDatasets MNIST Indexing](https://discourse.julialang.org/t/mldatasets-mnist-indexing/99246)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 0\
**Last updated:** [May 22, 2023, 7:07pm UTC](https://discourse.julialang.org/t/mldatasets-mnist-indexing/99246 "2023-05-22T19:07:49Z")

</div>

Why is it that if I look at an image from the MNIST dataset in MLDatasets as a matrix the rows and columns are switched? using MLDatasets using ImageShow trainset= MNIST(:train) A = trainset.features\[:,:,1\] So A\[1…

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

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