# General Usage

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

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

**Page:** 436

---

## [Understanding allocation pattern when using sort!()](https://discourse.julialang.org/t/understanding-allocation-pattern-when-using-sort/82794)

<div class="topic-metadata">

**Author:** [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Replies:** 12\
**Last updated:** [June 15, 2022, 8:42pm UTC](https://discourse.julialang.org/t/understanding-allocation-pattern-when-using-sort/82794 "2022-06-15T20:42:07Z")

</div>

Looked a bit closer into allocations of sort!() based on \`sort!()\` and \`sort()\` give me runtime dispatches and noticed the following which I’m trying to understand. using BenchmarkTools const N = 100 function makevect…

---

## [Making Word Embedding Layer in Julia](https://discourse.julialang.org/t/making-word-embedding-layer-in-julia/82829)

<div class="topic-metadata">

**Author:** [@Jack\_N](https://discourse.julialang.org/u/Jack_N)\
**Replies:** 2\
**Last updated:** [June 15, 2022, 8:17pm UTC](https://discourse.julialang.org/t/making-word-embedding-layer-in-julia/82829 "2022-06-15T20:17:23Z")

</div>

I am trying to make a word embedding layer in a flux model in Julia and I am using this tutorial as a reference https://spcman.github.io/getting-to-know-julia/deep-learning/nlp/flux-embeddings-tutorial-1/. I believe it …

---

## [Sorted product of infinite iterators](https://discourse.julialang.org/t/sorted-product-of-infinite-iterators/82755)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 9\
**Last updated:** [June 15, 2022, 7:57pm UTC](https://discourse.julialang.org/t/sorted-product-of-infinite-iterators/82755 "2022-06-15T19:57:10Z")

</div>

I have a collection of (potentially infinite) sorted iterators I1, I2, I3, … and a nondecreasing value function sort\_by((x1, x2, x3, ...)). I want the sorted cartesian product of these iterators. I’m thinking I can do t…

---

## [Use javascript library with Documenter.jl](https://discourse.julialang.org/t/use-javascript-library-with-documenter-jl/34984)

<div class="topic-metadata">

**Author:** [@mopg](https://discourse.julialang.org/u/mopg)\
**Replies:** 7\
**Last updated:** [June 15, 2022, 4:09pm UTC](https://discourse.julialang.org/t/use-javascript-library-with-documenter-jl/34984 "2022-06-15T16:09:08Z")

</div>

Does anyone know if it is possible to include an external javascript library with Documenter.jl? For example, I am trying to draw a flowchart, which should be possible with Markdown and flowchart.js, for example see exa…

---

## [Rewriting "Example 2: Calling Julia from Python" in Julia](https://discourse.julialang.org/t/rewriting-example-2-calling-julia-from-python-in-julia/82693)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 2\
**Last updated:** [June 15, 2022, 2:42pm UTC](https://discourse.julialang.org/t/rewriting-example-2-calling-julia-from-python-in-julia/82693 "2022-06-15T14:42:33Z")

</div>

I try to take the script shown in the link to Julia. example-2-calling-julia-from-python But in the following lines: loss = jl.seval("m -\> (x, y) -\> Flux.Losses.me(m(x), y)")(model) jl.Flux.train\_b( loss, jl.Fl…

---

## [\`sort!()\` and \`sort()\` give me runtime dispatches](https://discourse.julialang.org/t/sort-and-sort-give-me-runtime-dispatches/82715)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 2:21pm UTC](https://discourse.julialang.org/t/sort-and-sort-give-me-runtime-dispatches/82715 "2022-06-15T14:21:48Z")

</div>

I have been learning how to use JET.jl to check my code for type instabilities, and I notice that it keeps giving me a runtime dispatch after calling Julia’s built-iin sort routines. This happens even when my functions h…

---

## [Rigorous spectral opnorm](https://discourse.julialang.org/t/rigorous-spectral-opnorm/82739)

<div class="topic-metadata">

**Author:** [@mathmath](https://discourse.julialang.org/u/mathmath)\
**Replies:** 17\
**Last updated:** [June 15, 2022, 12:28pm UTC](https://discourse.julialang.org/t/rigorous-spectral-opnorm/82739 "2022-06-15T12:28:55Z")

</div>

I am wondering if there exists a way to rigorously compute spectral norms (an upper bound) of matrices (so the usual 2-norm for matrices) using the IntervalArithmetics package (GitHub - JuliaIntervals/IntervalArithmetic.…

---

## [Accelerate autodiff in Zygote.jl](https://discourse.julialang.org/t/accelerate-autodiff-in-zygote-jl/66454)

<div class="topic-metadata">

**Author:** [@Richard-Li](https://discourse.julialang.org/u/Richard-Li)\
**Replies:** 9\
**Last updated:** [June 15, 2022, 12:26pm UTC](https://discourse.julialang.org/t/accelerate-autodiff-in-zygote-jl/66454 "2022-06-15T12:26:35Z")

</div>

Hi there, I’d like to know if there is any performance tip for using Zygote.jl. I am calculating the Hessian matrix using autodiff, and now the autodiff part runs quite slow, and I’d like to accelerate it. e.g. 4.3…

---

## [How to Plot Arc of a circle with pyplot and Plots?](https://discourse.julialang.org/t/how-to-plot-arc-of-a-circle-with-pyplot-and-plots/82798)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 2\
**Last updated:** [June 15, 2022, 10:09am UTC](https://discourse.julialang.org/t/how-to-plot-arc-of-a-circle-with-pyplot-and-plots/82798 "2022-06-15T10:09:59Z")

</div>

Hi all, I have created this unit circle, and I want to plot an arc for the circle from point P to point (1,0) using Plots and pyplot. I want to bold the arc. Here is my code, I believe I might only need to add a line of…

---

## [ModelingToolkit @named](https://discourse.julialang.org/t/modelingtoolkit-named/82772)

<div class="topic-metadata">

**Author:** [@ccccc](https://discourse.julialang.org/u/ccccc)\
**Replies:** 4\
**Last updated:** [June 15, 2022, 9:09am UTC](https://discourse.julialang.org/t/modelingtoolkit-named/82772 "2022-06-15T09:09:15Z")

</div>

I am following the modeling toolkit examples, I am copy/pasting from: https://mtk.sciml.ai/stable/tutorials/ode\_modeling/ but @named is not working. Does anyone know why? @named fol = ODESystem(\[ D(x) ~ (1 - x)/τ\]) …

---

## [Garbage-collect intermediate module variables](https://discourse.julialang.org/t/garbage-collect-intermediate-module-variables/82747)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 3\
**Last updated:** [June 15, 2022, 6:53am UTC](https://discourse.julialang.org/t/garbage-collect-intermediate-module-variables/82747 "2022-06-15T06:53:23Z")

</div>

I often want to export some values (variables) from a module and am wondering how to delete intermediate variables. As an illustration: module somemod export var1, var2, . . . a1 = . . . # intermediate variables …

---

## [Custom arrays for dispatch](https://discourse.julialang.org/t/custom-arrays-for-dispatch/80100)

<div class="topic-metadata">

**Author:** [@Yly](https://discourse.julialang.org/u/Yly)\
**Replies:** 6\
**Last updated:** [June 15, 2022, 4:42am UTC](https://discourse.julialang.org/t/custom-arrays-for-dispatch/80100 "2022-06-15T04:42:04Z")

</div>

I have a situation where I am working with several qualitatively different types of arrays (arrays of phases, arrays of complex field amplitudes, arrays of intensities…). Although the data for each such array is the sam…

---

## [Surface plot](https://discourse.julialang.org/t/surface-plot/82544)

<div class="topic-metadata">

**Author:** [@SDA](https://discourse.julialang.org/u/SDA)\
**Replies:** 10\
**Last updated:** [June 15, 2022, 12:59am UTC](https://discourse.julialang.org/t/surface-plot/82544 "2022-06-15T00:59:49Z")

</div>

There is no doubt a very simple answer to this that I’ve overlooked. How would one plot a surface x=y, where z is any real number?

---

## [Does Julia have any utility to "split" RNGs for later use in parallel?](https://discourse.julialang.org/t/does-julia-have-any-utility-to-split-rngs-for-later-use-in-parallel/82775)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 4\
**Last updated:** [June 14, 2022, 11:03pm UTC](https://discourse.julialang.org/t/does-julia-have-any-utility-to-split-rngs-for-later-use-in-parallel/82775 "2022-06-14T23:03:45Z")

</div>

I want to generate some random numbers across a series of parallel processes, with a single input RNG provided by the user. Schematically I want something like: using Random rng = Xoshiro(1) # provided by user # gener…

---

## [How to efficiently sort subarrays of 2 large arrays in parallel?](https://discourse.julialang.org/t/how-to-efficiently-sort-subarrays-of-2-large-arrays-in-parallel/82771)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 0\
**Last updated:** [June 14, 2022, 5:40pm UTC](https://discourse.julialang.org/t/how-to-efficiently-sort-subarrays-of-2-large-arrays-in-parallel/82771 "2022-06-14T17:40:28Z")

</div>

I have large 1D arrays x and y, and pointers I that separate them into subarrays. My x and y barely fit into RAM and are of different dtypes (one contains UInt32’s, the other Rational{Int64}'s), so I don’t want to join t…

---

## [Why does Base.findmin assume that Combinatorics.Permutations has a \`keys\` method?](https://discourse.julialang.org/t/why-does-base-findmin-assume-that-combinatorics-permutations-has-a-keys-method/82774)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 3\
**Last updated:** [June 14, 2022, 7:03pm UTC](https://discourse.julialang.org/t/why-does-base-findmin-assume-that-combinatorics-permutations-has-a-keys-method/82774 "2022-06-14T19:03:29Z")

</div>

With Julia 1.8.0-rc1: julia\> using Combinatorics julia\> findmin(collect(permutations(1:3, 1))) # Works fine. (\[1\], 1) julia\> findmin(permutations(1:3, 1)) # Fails. ERROR: MethodError: no method matching keys(::Combi…

---

## [Some inconsistencies in an ensemble of stochastic differential equations](https://discourse.julialang.org/t/some-inconsistencies-in-an-ensemble-of-stochastic-differential-equations/82639)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 14\
**Last updated:** [June 14, 2022, 6:40pm UTC](https://discourse.julialang.org/t/some-inconsistencies-in-an-ensemble-of-stochastic-differential-equations/82639 "2022-06-14T18:40:21Z")

</div>

I am solving a stochastic differential equation using EnsembleProblem. When I then simply plot a summary of the solution, I get a reasonable result. However, when I calculate the mean myself using timeseries\_point\_mean…

---

## [Master versions in a Project.toml?](https://discourse.julialang.org/t/master-versions-in-a-project-toml/82766)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 2\
**Last updated:** [June 14, 2022, 5:44pm UTC](https://discourse.julialang.org/t/master-versions-in-a-project-toml/82766 "2022-06-14T17:44:46Z")

</div>

Is there a way to specify a package master version in a Project.toml file? The problem for me is that I’m working in a Franklin site and need fixes that I have to apply to GMT.jl but at same time I can’t (automatically)…

---

## [Dispatch of round()](https://discourse.julialang.org/t/dispatch-of-round/82756)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 3\
**Last updated:** [June 14, 2022, 4:40pm UTC](https://discourse.julialang.org/t/dispatch-of-round/82756 "2022-06-14T16:40:18Z")

</div>

hi here, I have a problem regarding the dispatching of round(): julia\> @enter round(2.2) \[ Info: tracking Base In round(x, r) at float.jl:380 \>380 round(x::Float64, r::RoundingMode{:Nearest}) = rint\_llvm(x) julia\> @en…

---

## [Having trouble importing hypernetx with PyCall](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395)

<div class="topic-metadata">

**Author:** [@Codzilla](https://discourse.julialang.org/u/Codzilla)\
**Replies:** 2\
**Last updated:** [June 14, 2022, 4:00pm UTC](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395 "2022-06-14T16:00:19Z")

</div>

While trying to use SimpleHypergraphs.jl visualization tools which require hypernetx (a python library), I encountered an error while running the following (which comes from the README of SimpleHypergraphs.jl ): usi…

---

## [Gridded Interpolation using Interpolation.jl not working in VSCode (but working in regular Julia repl)](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716)

<div class="topic-metadata">

**Author:** [@jpro](https://discourse.julialang.org/u/jpro)\
**Replies:** 7\
**Last updated:** [June 14, 2022, 3:28pm UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716 "2022-06-14T15:28:41Z")

</div>

Hi, I’d like to interpolate data from a 2d array in which the spacing is nonuniform. A is an 11x13 array that is imported from a .csv file, so below I just made it a random array of values (should be good enough while I’…

---

## [Generic way to dispatch on type of Union type](https://discourse.julialang.org/t/generic-way-to-dispatch-on-type-of-union-type/82745)

<div class="topic-metadata">

**Author:** [@manuelbb-upb](https://discourse.julialang.org/u/manuelbb-upb)\
**Replies:** 3\
**Last updated:** [June 14, 2022, 3:01pm UTC](https://discourse.julialang.org/t/generic-way-to-dispatch-on-type-of-union-type/82745 "2022-06-14T15:01:12Z")

</div>

Hi, I tried to write methods for a function (taking types as arguments) that should dispatch only if one argument supertypes the other, e.g., a\_supertypes\_b( a::Type, b::Type ) = "no" a\_supertypes\_b( ::Type{SUP}, ::Typ…

---

## [Is there a "correct" way to check if I am running a nightly build of Julia?](https://discourse.julialang.org/t/is-there-a-correct-way-to-check-if-i-am-running-a-nightly-build-of-julia/82754)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 0\
**Last updated:** [June 14, 2022, 2:59pm UTC](https://discourse.julialang.org/t/is-there-a-correct-way-to-check-if-i-am-running-a-nightly-build-of-julia/82754 "2022-06-14T14:59:51Z")

</div>

Is there an official way to check if I am running a non-release version of Julia? Any footguns to be aware of if I just do occursin("DEV",string(VERSION))? The reason for this question is that I want to permit certain t…

---

## [Defining a parameter out of pairs and values](https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701)

<div class="topic-metadata">

**Author:** [@noja](https://discourse.julialang.org/u/noja)\
**Replies:** 18\
**Last updated:** [June 14, 2022, 1:11pm UTC](https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701 "2022-06-14T13:11:48Z")

</div>

I have a set of pair like the following, and each pair comes with a value attached to it. For isntance the value of a pair (1,2) will be 2.5. There are another set of persons. Each person also connected to the subset of …

---

## [Fixing a parameter with Optimization.jl](https://discourse.julialang.org/t/fixing-a-parameter-with-optimization-jl/82663)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 9\
**Last updated:** [June 14, 2022, 1:11pm UTC](https://discourse.julialang.org/t/fixing-a-parameter-with-optimization-jl/82663 "2022-06-14T13:11:02Z")

</div>

Suppose I define the following problem which computes the maximum likelihood estimates (MLEs) for a regression problem using Optimization.jl: using Optimization, OptimizationOptimJL, Random, Distributions β₀, β₁, β₂, β₃…

---

## [Type of real part (of complex array element)](https://discourse.julialang.org/t/type-of-real-part-of-complex-array-element/82723)

<div class="topic-metadata">

**Author:** [@nicolas](https://discourse.julialang.org/u/nicolas)\
**Replies:** 8\
**Last updated:** [June 14, 2022, 1:00pm UTC](https://discourse.julialang.org/t/type-of-real-part-of-complex-array-element/82723 "2022-06-14T13:00:43Z")

</div>

I’m wondering whether there is a nice way of knowing the concrete type of the real part of a complex number, particularly something like eltype() for array elements. Right now, for an abstract array x, I’m using typeof(r…

---

## [Run Command without Single Quote](https://discourse.julialang.org/t/run-command-without-single-quote/23068)

<div class="topic-metadata">

**Author:** [@Eric\_Chen](https://discourse.julialang.org/u/Eric_Chen)\
**Replies:** 14\
**Last updated:** [June 14, 2022, 11:58am UTC](https://discourse.julialang.org/t/run-command-without-single-quote/23068 "2022-06-14T11:58:45Z")

</div>

Windows: I want Julia to run a command to 7-zip a file, i.e. following works in my terminal: 7z a c:\\test\\f1.zip c:\\test\\f1.txt I have to use Double Quote or No Quote for the file name, otherwise, If I use Single Q…

---

## [Get f from typeof(f)](https://discourse.julialang.org/t/get-f-from-typeof-f/82724)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 1\
**Last updated:** [June 14, 2022, 4:46am UTC](https://discourse.julialang.org/t/get-f-from-typeof-f/82724 "2022-06-14T04:46:28Z")

</div>

How can I get a function f, from the type of the function, i.e. typeof(f)? Here’s the full story, to avoid the XY problem: I’m using ChainRulesOverloadGeneration which is giving me typeof(f). I would like to run Base.re…

---

## [Does Reexport break Revise?](https://discourse.julialang.org/t/does-reexport-break-revise/82717)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 1\
**Last updated:** [June 14, 2022, 3:20am UTC](https://discourse.julialang.org/t/does-reexport-break-revise/82717 "2022-06-14T03:20:36Z")

</div>

Suppose one is defining the following package: module MyPackage using Reexport @reexport module Sub export f f() = 0 end end Let’s now play with it using Revise: using Revise using MyPackag…

---

## [Confusing behavior of btime](https://discourse.julialang.org/t/confusing-behavior-of-btime/82695)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 12\
**Last updated:** [June 13, 2022, 9:34pm UTC](https://discourse.julialang.org/t/confusing-behavior-of-btime/82695 "2022-06-13T21:34:41Z")

</div>

I have a small function f whose speed I am trying to optimize. Ideally, when the argument to f is a constant or type-inferred, the function should be compiled away. When using @btime I encountered some behavior I don’t …

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

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