# General Usage

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

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

**Page:** 591

---

## [Avoid ambiguities with individual number element (identity)](https://discourse.julialang.org/t/avoid-ambiguities-with-individual-number-element-identity/62465)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 5\
**Last updated:** [June 7, 2021, 1:26pm UTC](https://discourse.julialang.org/t/avoid-ambiguities-with-individual-number-element-identity/62465 "2021-06-07T13:26:01Z")

</div>

I have a question concerning the overloading of operators for an own type In our package on manifolds, we also cover Lie groups. These have an identity element (see Manifolds.jl/group.jl at 7e90c455804311f1220bcb52878fa…

---

## [X\[a,1\]'\*b\[a\]==sum(x\[a,1\].\*b\[a\])?](https://discourse.julialang.org/t/x-a-1-b-a-sum-x-a-1-b-a/62499)

<div class="topic-metadata">

**Author:** [@BYS](https://discourse.julialang.org/u/BYS)\
**Replies:** 2\
**Last updated:** [June 7, 2021, 11:55am UTC](https://discourse.julialang.org/t/x-a-1-b-a-sum-x-a-1-b-a/62499 "2021-06-07T11:55:54Z")

</div>

Hi, all If I input the following codes, julia\> b\[a\] 3-element Array{Any,1}: 1 2 3 julia\> a 3-element Array{Int64,1}: 2 3 4 julia\> model=Model(); julia\> @variable(model,x\[1:10,1:20\]) julia\> x\[a,1\]'\*b\[a\] there wil…

---

## [Closest distance between two Euclidian grids](https://discourse.julialang.org/t/closest-distance-between-two-euclidian-grids/61218)

<div class="topic-metadata">

**Author:** [@cadojo](https://discourse.julialang.org/u/cadojo)\
**Replies:** 19\
**Last updated:** [June 5, 2021, 3:20am UTC](https://discourse.julialang.org/t/closest-distance-between-two-euclidian-grids/61218 "2021-06-05T03:20:28Z")

</div>

I have two large data sets: A (size 1\_500\_000, 3), and B (size 1\_500, 3). I’d like to find the closest point between A and B. I could iterate through each possible combination, but that is O(n^2) and is not possible to c…

---

## [Inadequacy of UpperTriangular and LowerTriangular constructors](https://discourse.julialang.org/t/inadequacy-of-uppertriangular-and-lowertriangular-constructors/62509)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 0\
**Last updated:** [June 7, 2021, 11:29am UTC](https://discourse.julialang.org/t/inadequacy-of-uppertriangular-and-lowertriangular-constructors/62509 "2021-06-07T11:29:35Z")

</div>

The constructors for UpperTriangular and LowerTriangular only accept square matrices. However concepts such as diagaonl, upper triangular and lower triangular are defined for matrices of arbitrary dimensions. Here is an…

---

## [Executing code in @eval](https://discourse.julialang.org/t/executing-code-in-eval/62497)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [June 7, 2021, 10:13am UTC](https://discourse.julialang.org/t/executing-code-in-eval/62497 "2021-06-07T10:13:56Z")

</div>

Hey all, I don’t want to write lots of code and use @eval now. I want to generate different code depending on a condition inside @eval. It looks like this: for (sym, len) in ( (:sym1, nothing), (:sym2, 2) ) …

---

## [Threads.spawn - increment/decrement atomic variable](https://discourse.julialang.org/t/threads-spawn-increment-decrement-atomic-variable/62502)

<div class="topic-metadata">

**Author:** [@Michal](https://discourse.julialang.org/u/Michal)\
**Replies:** 5\
**Last updated:** [June 7, 2021, 10:09am UTC](https://discourse.julialang.org/t/threads-spawn-increment-decrement-atomic-variable/62502 "2021-06-07T10:09:21Z")

</div>

This is my working code, which is spawning threads. This example is working. while true M = pullDataFromQueue() if !isnothing(M) Threads.@spawn begin # Worker dela…

---

## [Sharing first coordinate](https://discourse.julialang.org/t/sharing-first-coordinate/62476)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [June 7, 2021, 8:42am UTC](https://discourse.julialang.org/t/sharing-first-coordinate/62476 "2021-06-07T08:42:42Z")

</div>

mx = mapping(:x) mx \* (mapping(\_, :y1 =\> :y) \* visual(Scatter) + mapping(\_, :y2 =\> :y) \* visual(Lines)) @piever How can I specify two different layers that share the same x coordinate without repeating myself?

---

## [Converting toggle button to slider for Interact.jl](https://discourse.julialang.org/t/converting-toggle-button-to-slider-for-interact-jl/62495)

<div class="topic-metadata">

**Author:** [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)\
**Replies:** 0\
**Last updated:** [June 7, 2021, 7:19am UTC](https://discourse.julialang.org/t/converting-toggle-button-to-slider-for-interact-jl/62495 "2021-06-07T07:19:51Z")

</div>

I have created an interactive plot for a dataframe df with column names a, b, c #= 5×5 DataFrame Row │ a b c │ Int64 Int64 Int64 ─────┼──────────────────────── 1 │ 1 3 2 …

---

## [How to tag a new version of my registered package](https://discourse.julialang.org/t/how-to-tag-a-new-version-of-my-registered-package/32842)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 4\
**Last updated:** [June 7, 2021, 7:06am UTC](https://discourse.julialang.org/t/how-to-tag-a-new-version-of-my-registered-package/32842 "2021-06-07T07:06:58Z")

</div>

Hi all, I’m trying to tag a new version of my (registered) package ForecastEval. In the past, I’ve always just created a new tag on github and then let attobot take care of the rest, but I seem to recall reading somethi…

---

## [Automatic differentiation for higher-order derivatives](https://discourse.julialang.org/t/automatic-differentiation-for-higher-order-derivatives/62337)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 11\
**Last updated:** [June 7, 2021, 12:40am UTC](https://discourse.julialang.org/t/automatic-differentiation-for-higher-order-derivatives/62337 "2021-06-07T00:40:01Z")

</div>

Hi, I would like to get some results from 0th to nth derivatives evaluation of a given function. For example, my\_func(x::Real) returns (f(x), f'(x), f''(x), ..., f^{n}(x)). Note that DiffResults.jl with ForwardDiff.j…

---

## [Operate only on a few components of a static vector](https://discourse.julialang.org/t/operate-only-on-a-few-components-of-a-static-vector/62409)

<div class="topic-metadata">

**Author:** [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Replies:** 14\
**Last updated:** [June 6, 2021, 5:09pm UTC](https://discourse.julialang.org/t/operate-only-on-a-few-components-of-a-static-vector/62409 "2021-06-06T17:09:39Z")

</div>

Suppose I want to extract and operate on only a few components from an SVector, e.g. using StaticArrays f( (x, y, z) ) = (3x, 4y, 5z) v = SVector( (2i for i in 1:10)...) indices = (1, 3, 5) v2 = getindex.(Ref(v), indi…

---

## [Reduced performance for parallel loops in larger code?](https://discourse.julialang.org/t/reduced-performance-for-parallel-loops-in-larger-code/62450)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 10\
**Last updated:** [June 6, 2021, 3:42pm UTC](https://discourse.julialang.org/t/reduced-performance-for-parallel-loops-in-larger-code/62450 "2021-06-06T15:42:30Z")

</div>

I’ve prepared a code that works pretty well in isolation. A minimal working example is below, but I’m basically taking values from a set of input arrays to another set of output arrays. Edit: I’m going to simplify thi…

---

## [Jupyter Kernel Dies (Julia exe deleted) with using Plots](https://discourse.julialang.org/t/jupyter-kernel-dies-julia-exe-deleted-with-using-plots/50566)

<div class="topic-metadata">

**Author:** [@KeithWoj](https://discourse.julialang.org/u/KeithWoj)\
**Replies:** 11\
**Last updated:** [June 6, 2021, 3:42pm UTC](https://discourse.julialang.org/t/jupyter-kernel-dies-julia-exe-deleted-with-using-plots/50566 "2021-06-06T15:42:15Z")

</div>

I installed Julia 1.5.3 and added IJulia using Pkg.add(“IJulia”) so that I can use a Jupyter notebook. I went through a Julia Academy tutorial with no issue until I got to the Packages lesson. In the terminal I entered: …

---

## [Synthetic control in julia](https://discourse.julialang.org/t/synthetic-control-in-julia/61615)

<div class="topic-metadata">

**Author:** [@Evan](https://discourse.julialang.org/u/Evan)\
**Replies:** 13\
**Last updated:** [June 5, 2021, 6:55pm UTC](https://discourse.julialang.org/t/synthetic-control-in-julia/61615 "2021-06-05T18:55:36Z")

</div>

Im currently trying to work through a question using synthetic control in r. link for context here: https://economics.mit.edu/files/17847 Ive found that the documentation is lacking and I have a syntax error. Has anyone…

---

## [Export Interactive Standalone HTML from WGLMakie](https://discourse.julialang.org/t/export-interactive-standalone-html-from-wglmakie/62412)

<div class="topic-metadata">

**Author:** [@src\_20](https://discourse.julialang.org/u/src_20)\
**Replies:** 4\
**Last updated:** [June 5, 2021, 8:40am UTC](https://discourse.julialang.org/t/export-interactive-standalone-html-from-wglmakie/62412 "2021-06-05T08:40:34Z")

</div>

Hi :slight\_smile: I want to use WGLMakie to extract static HTML, but my code does not work with the method described here. I think I wrote a bad code. Is there anyone who can suggest how to do this? The following work…

---

## [What is the difference between "rand(150) .\<= 0.1" and "rand(150) .= rand(150) .\<= 0.1"?](https://discourse.julialang.org/t/what-is-the-difference-between-rand-150-0-1-and-rand-150-rand-150-0-1/62418)

<div class="topic-metadata">

**Author:** [@achitsaz73](https://discourse.julialang.org/u/achitsaz73)\
**Replies:** 2\
**Last updated:** [June 5, 2021, 8:16am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-rand-150-0-1-and-rand-150-rand-150-0-1/62418 "2021-06-05T08:16:50Z")

</div>

It was my fault and I asked the wrong question. I apologize and delete the question.

---

## [When to use layoutable.attr = vs layoutable.attr\[\] =](https://discourse.julialang.org/t/when-to-use-layoutable-attr-vs-layoutable-attr/62405)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [June 5, 2021, 6:26am UTC](https://discourse.julialang.org/t/when-to-use-layoutable-attr-vs-layoutable-attr/62405 "2021-06-05T06:26:36Z")

</div>

using CairoMakie f = Figure() ax = Axis(f\[1, 1\]) markersizes = \[5, 10, 15, \] colors = \[:red, :green, :blue, :orange\] for ms in markersizes, color in colors scatter!(randn(5, 2), markersize = ms, color = color) e…

---

## [@turbo speeds routine, slows down everything else](https://discourse.julialang.org/t/turbo-speeds-routine-slows-down-everything-else/62163)

<div class="topic-metadata">

**Author:** [@rpmuller](https://discourse.julialang.org/u/rpmuller)\
**Replies:** 16\
**Last updated:** [June 5, 2021, 6:25am UTC](https://discourse.julialang.org/t/turbo-speeds-routine-slows-down-everything-else/62163 "2021-06-05T06:25:14Z")

</div>

I’ve been playing with LoopVectorization.jl to speed up the bottleneck in my code. I’ve included @turbo several times in the innermost loops in this routine, and nowhere else in the code. It currently speeds up that rout…

---

## [Is the JuliaRegistrator bot down?](https://discourse.julialang.org/t/is-the-juliaregistrator-bot-down/62415)

<div class="topic-metadata">

**Author:** [@cadojo](https://discourse.julialang.org/u/cadojo)\
**Replies:** 1\
**Last updated:** [June 5, 2021, 3:37am UTC](https://discourse.julialang.org/t/is-the-juliaregistrator-bot-down/62415 "2021-06-05T03:37:41Z")

</div>

I’m trying to register a new package, but the bot is not responding to my comment: Create main\_tests.yml · cadojo/AstrodynamicalModels.jl@07b7e4f · GitHub

---

## [@pure macro](https://discourse.julialang.org/t/pure-macro/3871)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 9\
**Last updated:** [June 5, 2021, 2:39am UTC](https://discourse.julialang.org/t/pure-macro/3871 "2021-06-05T02:39:22Z")

</div>

What does @pure do to a function? Is it faster in some cases?

---

## [Redefinition of functions sometimes possible?](https://discourse.julialang.org/t/redefinition-of-functions-sometimes-possible/62406)

<div class="topic-metadata">

**Author:** [@fedario](https://discourse.julialang.org/u/fedario)\
**Replies:** 7\
**Last updated:** [June 4, 2021, 9:36pm UTC](https://discourse.julialang.org/t/redefinition-of-functions-sometimes-possible/62406 "2021-06-04T21:36:04Z")

</div>

Hi! I noticed some unexpected (at least for me) behavior when redefining functions. julia\> foo(x) = x + 1 foo (generic function with 1 method) julia\> foo(x) = x + 2 foo (generic function with 1 method) julia\> foo = x…

---

## [Cartesian product legend](https://discourse.julialang.org/t/cartesian-product-legend/62370)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 3\
**Last updated:** [June 4, 2021, 8:07pm UTC](https://discourse.julialang.org/t/cartesian-product-legend/62370 "2021-06-04T20:07:54Z")

</div>

Is it possible to have legend with red green blue orange 05 10 15 20 with sized colored images in each cell and row/column labels? f = Figure() Axis(f\[1, 1\]) markersizes = \[5, 10, 15, 20\] colors…

---

## [Int / Float type inference in constructor](https://discourse.julialang.org/t/int-float-type-inference-in-constructor/62395)

<div class="topic-metadata">

**Author:** [@jinml](https://discourse.julialang.org/u/jinml)\
**Replies:** 5\
**Last updated:** [June 4, 2021, 6:16pm UTC](https://discourse.julialang.org/t/int-float-type-inference-in-constructor/62395 "2021-06-04T18:16:13Z")

</div>

I defined a struct as follows: struct inverse{T\<:Number} x::Array{T} y::Array{T} function inverse{T}(x0::Tuple{...,T,...}) where T\<:Number x = convert\_to\_x(x0) y = inv(x) new(promote(x,y)...) end end where the construc…

---

## [Download packages error on Julia 0.4.7](https://discourse.julialang.org/t/download-packages-error-on-julia-0-4-7/62336)

<div class="topic-metadata">

**Author:** [@JDA](https://discourse.julialang.org/u/JDA)\
**Replies:** 6\
**Last updated:** [June 4, 2021, 11:50am UTC](https://discourse.julialang.org/t/download-packages-error-on-julia-0-4-7/62336 "2021-06-04T11:50:48Z")

</div>

Hello, I am working on setting up Julia on a new computer that is running Catalina. A few versions of Julia are currently installed, but I’m having trouble setting up / downloading packages. I’ve never seen error like …

---

## [Plots.jl: Fill overlaps with x/y-axis](https://discourse.julialang.org/t/plots-jl-fill-overlaps-with-x-y-axis/62330)

<div class="topic-metadata">

**Author:** [@scipham](https://discourse.julialang.org/u/scipham)\
**Replies:** 4\
**Last updated:** [June 4, 2021, 7:26am UTC](https://discourse.julialang.org/t/plots-jl-fill-overlaps-with-x-y-axis/62330 "2021-06-04T07:26:26Z")

</div>

I use the following for plotting with Plots.jl: using Plots using HDF5 using Statistics all\_predictions = \[\] all\_trueValues = \[\] h5open("3to12benchmark\_corrected\_r.dat", "r") do fid for qn in 3:10 predictions = …

---

## [Download packages error on Julia 1.1.1](https://discourse.julialang.org/t/download-packages-error-on-julia-1-1-1/62339)

<div class="topic-metadata">

**Author:** [@JDA](https://discourse.julialang.org/u/JDA)\
**Replies:** 6\
**Last updated:** [June 4, 2021, 3:48am UTC](https://discourse.julialang.org/t/download-packages-error-on-julia-1-1-1/62339 "2021-06-04T03:48:48Z")

</div>

Hello, I am working on setting up Julia on a new computer that is running Catalina. A few versions of Julia are currently installed, but I’m having trouble setting up / downloading packages. I’ve never seen error like t…

---

## [PyCall Issues with MKL](https://discourse.julialang.org/t/pycall-issues-with-mkl/62354)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 1\
**Last updated:** [June 4, 2021, 3:06am UTC](https://discourse.julialang.org/t/pycall-issues-with-mkl/62354 "2021-06-04T03:06:14Z")

</div>

I want to call a tiny bit of Python code that makes use of some FEniCS code, so I tried adding PyCall and building it against the (conda) Python environment on my system for which I have FEniCS working. However, this en…

---

## [Inserting new abstract type into existing hierarchy?](https://discourse.julialang.org/t/inserting-new-abstract-type-into-existing-hierarchy/62365)

<div class="topic-metadata">

**Author:** [@lamorton](https://discourse.julialang.org/u/lamorton)\
**Replies:** 7\
**Last updated:** [June 4, 2021, 2:05am UTC](https://discourse.julialang.org/t/inserting-new-abstract-type-into-existing-hierarchy/62365 "2021-06-04T02:05:24Z")

</div>

Suppose an existing package Barnyard defines abstract type Animal end abstract type Dog \<: Animal end Let’s say that in my package Zoo I define two new types: using Barnyard abstract type Zebra \<: Animal end abstract …

---

## [Directional derivative with automatic differentiation](https://discourse.julialang.org/t/directional-derivative-with-automatic-differentiation/62305)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 4\
**Last updated:** [June 4, 2021, 1:48am UTC](https://discourse.julialang.org/t/directional-derivative-with-automatic-differentiation/62305 "2021-06-04T01:48:49Z")

</div>

Hello, I would like to compute the directional derivative of a vector-valued function f at a point x along the direction v, i.e. \\nabla f(x) \\cdot v using ForwardDiff.jl. From what I understood, it is possible to comp…

---

## [Parallel sampling](https://discourse.julialang.org/t/parallel-sampling/62310)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 5\
**Last updated:** [June 4, 2021, 12:57am UTC](https://discourse.julialang.org/t/parallel-sampling/62310 "2021-06-04T00:57:35Z")

</div>

it is the first time i’m trying the parallel computing and before i go to my actual code, i decided to try it on a simple code to see the speed of the execution of the code @everywhere function sampler(x, y) z=…

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

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