# General Usage

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

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

**Page:** 412

---

## [Help defining a custom SVector](https://discourse.julialang.org/t/help-defining-a-custom-svector/85424)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 7\
**Last updated:** [August 8, 2022, 11:43pm UTC](https://discourse.julialang.org/t/help-defining-a-custom-svector/85424 "2022-08-08T23:43:06Z")

</div>

The StaticArrays.jl documentation mentions the FieldVector abstract type that developers can use to inherit all the nice behavior of SVector: using StaticArrays struct Vec{T} \<: FieldVector{3,T} x::T y::T z::T en…

---

## [Question about AlgebraOfGraphics](https://discourse.julialang.org/t/question-about-algebraofgraphics/85481)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 2\
**Last updated:** [August 8, 2022, 8:40pm UTC](https://discourse.julialang.org/t/question-about-algebraofgraphics/85481 "2022-08-08T20:40:40Z")

</div>

Dear all, When I use AlgebraOfGraphics.jl, How can I hide the legend title? Here is an example. using RDatasets, AlgebraOfGraphics, CairoMakie df = dataset("datasets", "iris") plt = data(df) \* mapping(:Species, :SepalL…

---

## [Alternatives to Query.jl for aggregation](https://discourse.julialang.org/t/alternatives-to-query-jl-for-aggregation/85496)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [August 8, 2022, 6:32pm UTC](https://discourse.julialang.org/t/alternatives-to-query-jl-for-aggregation/85496 "2022-08-08T18:32:42Z")

</div>

Hi everybody, I am looking for a way to aggregate my data like Query.jl. Usually, I would run something like: test\_df = DataFrame(A = \[1,1,2,2\], B = \[missing, 1, missing, 2\]) df\_agg = test\_df |\> @groupby(\_.A) |\>…

---

## [Julia BlackBoxOptim set the threshold for determining convergence in the fitness value?](https://discourse.julialang.org/t/julia-blackboxoptim-set-the-threshold-for-determining-convergence-in-the-fitness-value/85494)

<div class="topic-metadata">

**Author:** [@jfanecon](https://discourse.julialang.org/u/jfanecon)\
**Replies:** 0\
**Last updated:** [August 8, 2022, 5:14pm UTC](https://discourse.julialang.org/t/julia-blackboxoptim-set-the-threshold-for-determining-convergence-in-the-fitness-value/85494 "2022-08-08T17:14:30Z")

</div>

Hi, I am using Julia BlackBoxOptim to search for global optima of a function, using default optimizer. The fitness value keeps unchanged for 150 evaluations, so I am wondering whether it is possible to have an option si…

---

## [Solving German Tank Problem by Turing ,but](https://discourse.julialang.org/t/solving-german-tank-problem-by-turing-but/85493)

<div class="topic-metadata">

**Author:** [@kimseok1973](https://discourse.julialang.org/u/kimseok1973)\
**Replies:** 0\
**Last updated:** [August 8, 2022, 5:12pm UTC](https://discourse.julialang.org/t/solving-german-tank-problem-by-turing-but/85493 "2022-08-08T17:12:57Z")

</div>

I would like to solve “German Tank Ploblem” by Turing.jl but it will not work when a model use DiscreteUniform. ss = rand(DiscreteUniform(1,60),8) @model function tank(ds) m ~ Uniform(2,2000) ds .~ Uniform(1,m)…

---

## [Comparing exp() performance on Julia versus numpy](https://discourse.julialang.org/t/comparing-exp-performance-on-julia-versus-numpy/85325)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 38\
**Last updated:** [August 8, 2022, 4:12pm UTC](https://discourse.julialang.org/t/comparing-exp-performance-on-julia-versus-numpy/85325 "2022-08-08T16:12:15Z")

</div>

So I was actually preparing a demo to show off Julia to colleagues when I encountered this issue. I want to simply compute the exponential of an array. In Julia (v. 1.7.2): arr = rand(100\_000) @benchmark exp.($arr) # …

---

## [Unconventional use of \`merge\`](https://discourse.julialang.org/t/unconventional-use-of-merge/85472)

<div class="topic-metadata">

**Author:** [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Replies:** 2\
**Last updated:** [August 8, 2022, 2:40pm UTC](https://discourse.julialang.org/t/unconventional-use-of-merge/85472 "2022-08-08T14:40:57Z")

</div>

TL;DR: I understand at a high level what this code is doing, but the implementation is very unusual and I don’t understand what is going on. I have the following the code that someone else wrote: """ deep\_merge(d..…

---

## [Check type stability of a struct](https://discourse.julialang.org/t/check-type-stability-of-a-struct/85343)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 5\
**Last updated:** [August 8, 2022, 2:28pm UTC](https://discourse.julialang.org/t/check-type-stability-of-a-struct/85343 "2022-08-08T14:28:45Z")

</div>

We usually speak of type stability for functions and we also have the tools to determine that (like @code\_warntype). But say I would like to check whether a struct is type-stable, in the sense that it is well defined an…

---

## [Performance of printing a type name](https://discourse.julialang.org/t/performance-of-printing-a-type-name/85468)

<div class="topic-metadata">

**Author:** [@ikirill](https://discourse.julialang.org/u/ikirill)\
**Replies:** 3\
**Last updated:** [August 8, 2022, 2:27pm UTC](https://discourse.julialang.org/t/performance-of-printing-a-type-name/85468 "2022-08-08T14:27:14Z")

</div>

Is this expected, or is this a bug? Printing Val(:hello\_world) is ~1000 times slower than printing :hello\_world, and I imagine this affects things like printing stack traces with complicated types. julia\> @benchmark str…

---

## [Let-in macro](https://discourse.julialang.org/t/let-in-macro/85431)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 6\
**Last updated:** [August 8, 2022, 1:03pm UTC](https://discourse.julialang.org/t/let-in-macro/85431 "2022-08-08T13:03:29Z")

</div>

I want a macro like this: @let begin a = 1 b = 2 in y = a + b z = a - b end defines in the containing scope y and z in terms of a and b, without defining a and b in the containing scope. How can I do this?

---

## [Dateformat Makie](https://discourse.julialang.org/t/dateformat-makie/85381)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 2\
**Last updated:** [August 8, 2022, 12:55pm UTC](https://discourse.julialang.org/t/dateformat-makie/85381 "2022-08-08T12:55:31Z")

</div>

In AoG I’m trying to do draw(;axis=(;xtickformat=dateformat"yyyy-mm")) . How can I get what I want?

---

## [Juliad and julias, wrappers to DaemonMode and -J sysimage for quicker Linux/Cygwin scripts](https://discourse.julialang.org/t/juliad-and-julias-wrappers-to-daemonmode-and-j-sysimage-for-quicker-linux-cygwin-scripts/76690)

<div class="topic-metadata">

**Author:** [@jdad](https://discourse.julialang.org/u/jdad)\
**Replies:** 3\
**Last updated:** [August 8, 2022, 11:00am UTC](https://discourse.julialang.org/t/juliad-and-julias-wrappers-to-daemonmode-and-j-sysimage-for-quicker-linux-cygwin-scripts/76690 "2022-08-08T11:00:55Z")

</div>

FWIW, as an old linuxer, I have created for my own usage two scripts to facilitate the use of either sysimage or DaermonMode.jl to get faster frequently used scripts (=faster TTFX, Time to First X). Sorry, I have done th…

---

## [Intersection Symbol in Latex with PyPlotJS](https://discourse.julialang.org/t/intersection-symbol-in-latex-with-pyplotjs/85462)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 6\
**Last updated:** [August 8, 2022, 7:49am UTC](https://discourse.julialang.org/t/intersection-symbol-in-latex-with-pyplotjs/85462 "2022-08-08T07:49:39Z")

</div>

Hi all, I am playing around by creating venn diagram today, I want to know why I can’t make the intersection symbol appeared? Is it impossible? Thanks Here is the code: using PlotlyJS, LaTeXStrings # Create scatter t…

---

## [Related or linked structures](https://discourse.julialang.org/t/related-or-linked-structures/85463)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 0\
**Last updated:** [August 8, 2022, 7:45am UTC](https://discourse.julialang.org/t/related-or-linked-structures/85463 "2022-08-08T07:45:46Z")

</div>

Is it possible to connect data structures, similar to Primary-Key Foreign-Key connections in a relational database? One way could be to have a type similar to enum that would limit a field to a given set of values. Usi…

---

## [Performance of creating a demo dataset](https://discourse.julialang.org/t/performance-of-creating-a-demo-dataset/85441)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [August 8, 2022, 2:56am UTC](https://discourse.julialang.org/t/performance-of-creating-a-demo-dataset/85441 "2022-08-08T02:56:38Z")

</div>

I have the following code: using InMemoryDatasets function demo\_data() ds = Dataset(time=0.0, d1=10, d2=20, d3=30) time = 0.1 for i in 1:100000 if i == 5 d1 = missing else …

---

## [Startup without $HOME on AWS](https://discourse.julialang.org/t/startup-without-home-on-aws/85452)

<div class="topic-metadata">

**Author:** [@sparrowhawk](https://discourse.julialang.org/u/sparrowhawk)\
**Replies:** 1\
**Last updated:** [August 8, 2022, 1:39am UTC](https://discourse.julialang.org/t/startup-without-home-on-aws/85452 "2022-08-08T01:39:17Z")

</div>

Hi all, I’m trying to run Julia on Amazon Workspaces, where all users at our workshop can simply spin up Julia and VSCode on a virtual 8 core Windows 10 machine. However, every time I spin up a new workspace, the windows…

---

## ["add Plots" giving error](https://discourse.julialang.org/t/add-plots-giving-error/72094)

<div class="topic-metadata">

**Author:** [@majid](https://discourse.julialang.org/u/majid)\
**Replies:** 0\
**Last updated:** [November 26, 2021, 5:34am UTC](https://discourse.julialang.org/t/add-plots-giving-error/72094 "2021-11-26T05:34:41Z")

</div>

This post is deleted.

---

## [Can DataFrames be distinguished by type?](https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 1\
**Last updated:** [August 7, 2022, 11:31pm UTC](https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442 "2022-08-07T23:31:46Z")

</div>

I would like to have a function call fail or not depending on the type of a DataFrame. I cannot distinguish the DataFrames by column types or size. For example, I would have two identical functions except for the argume…

---

## [A vector with custom indices](https://discourse.julialang.org/t/a-vector-with-custom-indices/85373)

<div class="topic-metadata">

**Author:** [@moataz-sabry](https://discourse.julialang.org/u/moataz-sabry)\
**Replies:** 15\
**Last updated:** [August 7, 2022, 11:18pm UTC](https://discourse.julialang.org/t/a-vector-with-custom-indices/85373 "2022-08-07T23:18:18Z")

</div>

is it possible to have a vector with custom predefined non-uniform indexing. Like the following made-up example, I’ve a vector with the values 1, 2, 3 of the indices 29, 360, 400. x = \[1, 2, 3\] for (i, v) in enumerate(…

---

## [Parameter estimation of an ODE in Julia is slower than in R](https://discourse.julialang.org/t/parameter-estimation-of-an-ode-in-julia-is-slower-than-in-r/85114)

<div class="topic-metadata">

**Author:** [@laurar1891](https://discourse.julialang.org/u/laurar1891)\
**Replies:** 25\
**Last updated:** [August 7, 2022, 11:15pm UTC](https://discourse.julialang.org/t/parameter-estimation-of-an-ode-in-julia-is-slower-than-in-r/85114 "2022-08-07T23:15:04Z")

</div>

I’ve been trying to estimate parameters (using max likelihood) of an ODE using the DifferentialEquations and Optim packages in Julia aiming to get a faster convergence compared to R. Problem is that I still can do it fas…

---

## [@enum multiplication](https://discourse.julialang.org/t/enum-multiplication/85213)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 12\
**Last updated:** [August 7, 2022, 11:04pm UTC](https://discourse.julialang.org/t/enum-multiplication/85213 "2022-08-07T23:04:36Z")

</div>

Is this the best way to do this? @enum BuySell (Buy=1; Sell=-1) import Base.\* \*(x::BuySell, y::Any ) = Int(x) \* y \*(y::Any, x::BuySell) = y \* Int(x) Sell \* 10 # = -10 So I can put \* Buy o…

---

## [Faster matrix product with a specifically structured matrix](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 26\
**Last updated:** [August 7, 2022, 8:47pm UTC](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355 "2022-08-07T20:47:56Z")

</div>

Hi, I have a sparse matrix P that turns out to have only equal values (or zeros) on each line: julia\> all(\[sum(unique(P\[i,:\]).!=0)\<=1 for i in 1:size(P,1)\]) true julia\> Where I used \<=1 since some lines are complete…

---

## [Is there any rule to arrange the order of definitions of variables, functions, types, macros in a module?](https://discourse.julialang.org/t/is-there-any-rule-to-arrange-the-order-of-definitions-of-variables-functions-types-macros-in-a-module/85421)

<div class="topic-metadata">

**Author:** [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Replies:** 6\
**Last updated:** [August 7, 2022, 10:21pm UTC](https://discourse.julialang.org/t/is-there-any-rule-to-arrange-the-order-of-definitions-of-variables-functions-types-macros-in-a-module/85421 "2022-08-07T22:21:03Z")

</div>

I just found that a type or macro should be declared before being called, but a function is not. Is it to say that functions can be placed in an arbitrary order confined by the only requirment that they must be placed a…

---

## [PackageCompiler: Do optimisation flags influence the produced sysimages?](https://discourse.julialang.org/t/packagecompiler-do-optimisation-flags-influence-the-produced-sysimages/47338)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 0\
**Last updated:** [September 26, 2020, 9:07pm UTC](https://discourse.julialang.org/t/packagecompiler-do-optimisation-flags-influence-the-produced-sysimages/47338 "2020-09-26T21:07:34Z")

</div>

Is there a difference between julia -O3 -e "import PackageCompiler; PackageCompiler.create\_sysimage(...)" vs julia -e "import PackageCompiler; PackageCompiler.create\_sysimage(...)"? Are the produced sysimages the sa…

---

## [Pluto Sysimage](https://discourse.julialang.org/t/pluto-sysimage/75106)

<div class="topic-metadata">

**Author:** [@Timothy](https://discourse.julialang.org/u/Timothy)\
**Replies:** 0\
**Last updated:** [January 24, 2022, 7:04am UTC](https://discourse.julialang.org/t/pluto-sysimage/75106 "2022-01-24T07:04:47Z")

</div>

I am trying to generate a sysimage for my workflow in Pluto. I have specified my notebook file as the precompile execution file in VSCode. However - I can’t generate a sysimage in VSCode. I wonder whether I can not gen…

---

## [EOOR: failed process when using PackageCompiler.create\_sysimage](https://discourse.julialang.org/t/eoor-failed-process-when-using-packagecompiler-create-sysimage/40607)

<div class="topic-metadata">

**Author:** [@yy38819991](https://discourse.julialang.org/u/yy38819991)\
**Replies:** 0\
**Last updated:** [June 2, 2020, 11:26am UTC](https://discourse.julialang.org/t/eoor-failed-process-when-using-packagecompiler-create-sysimage/40607 "2020-06-02T11:26:02Z")

</div>

When I used PackageCompiler.create\_sysimage in Linux OS, an error occurred. Then I tried the same work in another server with Linux OS and the same error appeared. But when I first used the package in my Windows10 comput…

---

## [Download package in julia](https://discourse.julialang.org/t/download-package-in-julia/85445)

<div class="topic-metadata">

**Author:** [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Replies:** 1\
**Last updated:** [August 7, 2022, 7:33pm UTC](https://discourse.julialang.org/t/download-package-in-julia/85445 "2022-08-07T19:33:33Z")

</div>

Hi, I want to download kNN package in julia. The link is KNN · Julia Packages My code is using Pkg Pkg.add("kNN") And I got error kNN (not found in project, manifest or registry) But I can download other packages…

---

## [LoadError: MethodError: no method matching open(::Nothing, ::String)](https://discourse.julialang.org/t/loaderror-methoderror-no-method-matching-open-nothing-string/85438)

<div class="topic-metadata">

**Author:** [@caozhr](https://discourse.julialang.org/u/caozhr)\
**Replies:** 1\
**Last updated:** [August 7, 2022, 5:43pm UTC](https://discourse.julialang.org/t/loaderror-methoderror-no-method-matching-open-nothing-string/85438 "2022-08-07T17:43:51Z")

</div>

I’m new to Julia. Here, some problems really puzzled me. here is my pipeline, and I think a mistake occurs in line 38: I don’t know how to modify it. The mistake is: ERROR: LoadError: MethodError: no method matching…

---

## [Mapping a value from one range to another](https://discourse.julialang.org/t/mapping-a-value-from-one-range-to-another/85423)

<div class="topic-metadata">

**Author:** [@GameDungeon](https://discourse.julialang.org/u/GameDungeon)\
**Replies:** 11\
**Last updated:** [August 7, 2022, 5:34pm UTC](https://discourse.julialang.org/t/mapping-a-value-from-one-range-to-another/85423 "2022-08-07T17:34:46Z")

</div>

I have two ranges a and b. a = 1:10 b = 1:100 I have a value from a, say 5. If I were to map it onto range b its equivalent would be 50. In python you can write a function that does this like this: def map\_range(range…

---

## [Type stability when using fields of structs](https://discourse.julialang.org/t/type-stability-when-using-fields-of-structs/85408)

<div class="topic-metadata">

**Author:** [@Jonas208](https://discourse.julialang.org/u/Jonas208)\
**Replies:** 12\
**Last updated:** [August 7, 2022, 12:43pm UTC](https://discourse.julialang.org/t/type-stability-when-using-fields-of-structs/85408 "2022-08-07T12:43:34Z")

</div>

I am trying to optimize a function which mainly operates on arrays that are (nearly all) fields of a given struct. Yet, the performance of the function is NOT really fast. My first idea was to check type stability and ty…

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

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