# General Usage

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

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

**Page:** 178

---

## [Julia plots: Labels in scientific notation as in default font](https://discourse.julialang.org/t/julia-plots-labels-in-scientific-notation-as-in-default-font/113231)

<div class="topic-metadata">

**Author:** [@james](https://discourse.julialang.org/u/james)\
**Replies:** 2\
**Last updated:** [April 19, 2024, 5:27pm UTC](https://discourse.julialang.org/t/julia-plots-labels-in-scientific-notation-as-in-default-font/113231 "2024-04-19T17:27:32Z")

</div>

I have a log log plot and want to change the x-axis labels manually as in the code below. Hence, I need to use powers of 10 – however, the only ways I come up with gives different fonts than the default: Note that bo…

---

## [Plot legend with multiple columns](https://discourse.julialang.org/t/plot-legend-with-multiple-columns/29195)

<div class="topic-metadata">

**Author:** [@aurelio-amerio](https://discourse.julialang.org/u/aurelio-amerio)\
**Replies:** 8\
**Last updated:** [April 19, 2024, 3:10pm UTC](https://discourse.julialang.org/t/plot-legend-with-multiple-columns/29195 "2024-04-19T15:10:12Z")

</div>

Hello, is there a way to split the labels in the legend in two columns using Plots.jl? I know how to do it using PyPlot (just use legend(ncol=2)) but I would like to avoid using python, if possible. Thank you very much…

---

## [Indices of intersection of two arrays](https://discourse.julialang.org/t/indices-of-intersection-of-two-arrays/23043)

<div class="topic-metadata">

**Author:** [@wonderboy3489](https://discourse.julialang.org/u/wonderboy3489)\
**Replies:** 25\
**Last updated:** [April 19, 2024, 2:09pm UTC](https://discourse.julialang.org/t/indices-of-intersection-of-two-arrays/23043 "2024-04-19T14:09:41Z")

</div>

Suppose I have two arrays: a = \[2, 4, 6, 7, 10, 11\] b = \[6, 7, 10, 11, 13, 15, 17, 19, 21, 23\] How do I get the indices of values in b that are in a and vice versa? I know intersection() returns the values, but I’m aft…

---

## [Unable to add any packages](https://discourse.julialang.org/t/unable-to-add-any-packages/113147)

<div class="topic-metadata">

**Author:** [@Sharara](https://discourse.julialang.org/u/Sharara)\
**Replies:** 4\
**Last updated:** [April 19, 2024, 2:09pm UTC](https://discourse.julialang.org/t/unable-to-add-any-packages/113147 "2024-04-19T14:09:03Z")

</div>

Dear all I have a problem with Julia, I had to stop working on my project in Julia for a while, The last time (around 2 weeks ago, everything worked well) but yesterday when I got back to my work and opened Julia, I …

---

## [How is \`deepcopy\` so clever regarding aliasing and self-reference?](https://discourse.julialang.org/t/how-is-deepcopy-so-clever-regarding-aliasing-and-self-reference/113235)

<div class="topic-metadata">

**Author:** [@iago-lito](https://discourse.julialang.org/u/iago-lito)\
**Replies:** 4\
**Last updated:** [April 19, 2024, 1:43pm UTC](https://discourse.julialang.org/t/how-is-deepcopy-so-clever-regarding-aliasing-and-self-reference/113235 "2024-04-19T13:43:10Z")

</div>

I find this behaviour very fortunate, but also black magic: a = \[5\] u = \[a, a, a\] v = deepcopy(u) v\[1\]\[1\] = 8 v # \[\[8\], \[8\], \[8\]\] # My naive 'deepcopy' would have produced \[\[8\], \[5\], \[5\]\] instead. I expected deepcopy …

---

## [Define a C++ struct/class in Julia for interop?](https://discourse.julialang.org/t/define-a-c-struct-class-in-julia-for-interop/112766)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 11\
**Last updated:** [April 19, 2024, 1:07pm UTC](https://discourse.julialang.org/t/define-a-c-struct-class-in-julia-for-interop/112766 "2024-04-19T13:07:22Z")

</div>

To efficiently call C or C++ libraries without an additional overhead of dereferencing pointers, you need to define a Julia struct with the same memory layout as the the struct/class in C or C++. For C, Clang.jl and CBin…

---

## [Best practices (for package code), e.g. no "using"](https://discourse.julialang.org/t/best-practices-for-package-code-e-g-no-using/113233)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [April 19, 2024, 12:54pm UTC](https://discourse.julialang.org/t/best-practices-for-package-code-e-g-no-using/113233 "2024-04-19T12:54:14Z")

</div>

E.g. using is “considered harmful” for package code. There’s disagreement on recommending against it in the Julia docs, but it can for sure go into some style-guide, and maybe is already there. eval should neither be use…

---

## [Best performance for initialising a variable number of matrices/vectors within a Crank-Nicolson scheme](https://discourse.julialang.org/t/best-performance-for-initialising-a-variable-number-of-matrices-vectors-within-a-crank-nicolson-scheme/113083)

<div class="topic-metadata">

**Author:** [@lhcgeneva](https://discourse.julialang.org/u/lhcgeneva)\
**Replies:** 4\
**Last updated:** [April 19, 2024, 6:56am UTC](https://discourse.julialang.org/t/best-performance-for-initialising-a-variable-number-of-matrices-vectors-within-a-crank-nicolson-scheme/113083 "2024-04-19T06:56:05Z")

</div>

I’m solving a diffusion problem of several connected domains. I use a Crank-Nicolson scheme on each domain, and at every time step I connect the domains by some matching conditions at the boundary. To do the Crank-Nicols…

---

## [Is there a result type library?](https://discourse.julialang.org/t/is-there-a-result-type-library/113224)

<div class="topic-metadata">

**Author:** [@minetest2048](https://discourse.julialang.org/u/minetest2048)\
**Replies:** 2\
**Last updated:** [April 19, 2024, 11:21am UTC](https://discourse.julialang.org/t/is-there-a-result-type-library/113224 "2024-04-19T11:21:02Z")

</div>

I really missed my Result type from Rust, so I’ve keep writing this on my libraries using SumTypes.jl: using SumTypes @sum\_type Result{A, B} begin Ok{A}(::A) Err{B}(::B) end #Some functions to work with result…

---

## [Convenient creation of an OffsetArray?](https://discourse.julialang.org/t/convenient-creation-of-an-offsetarray/113047)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 5\
**Last updated:** [April 19, 2024, 11:01am UTC](https://discourse.julialang.org/t/convenient-creation-of-an-offsetarray/113047 "2024-04-19T11:01:04Z")

</div>

I’ve been using OffsetArrays and is a bit frustrated with its cumbersome creation: # xax\[0:imax\], zax\[0:kmax\] are OffsetArrays. # I want to create an OffsetArray \[0:imax, 0:kmax\] oa = OffsetArray(Array{Float64,2}(undef,…

---

## [Package update fails when downloading registries, 502 bad gateway](https://discourse.julialang.org/t/package-update-fails-when-downloading-registries-502-bad-gateway/113220)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 0\
**Last updated:** [April 19, 2024, 6:28am UTC](https://discourse.julialang.org/t/package-update-fails-when-downloading-registries-502-bad-gateway/113220 "2024-04-19T06:28:38Z")

</div>

https://pkg.julialang.org/registries redirects to https://eu-central.pkg.julialang.org/registries which results in HTTP error 502 “bad gateway”. EDIT: works now

---

## [Unable to create parallel package](https://discourse.julialang.org/t/unable-to-create-parallel-package/113207)

<div class="topic-metadata">

**Author:** [@jafagervik](https://discourse.julialang.org/u/jafagervik)\
**Replies:** 1\
**Last updated:** [April 19, 2024, 5:52am UTC](https://discourse.julialang.org/t/unable-to-create-parallel-package/113207 "2024-04-19T05:52:55Z")

</div>

Hi, I’m trying to make a package in which I use Distributed.jl a bit. Lets call it Intro.jl, and I have two files in src directory. Intro.jl contains this code: module Intro using Distributed export mad, meap include…

---

## [How to configurate bound checks at statup?](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248)

<div class="topic-metadata">

**Author:** [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Replies:** 4\
**Last updated:** [April 18, 2024, 11:26pm UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248 "2024-04-18T23:26:58Z")

</div>

For well tested code it will be nice to have an option at the startup which disables the check bounds. According to the book JULIA HIGH PERFORMACE this is possible with the following option: -checks-bounds=no Neverthel…

---

## [Can DataFramesMeta replace dummy values for all columns of a specific type](https://discourse.julialang.org/t/can-dataframesmeta-replace-dummy-values-for-all-columns-of-a-specific-type/113149)

<div class="topic-metadata">

**Author:** [@jjAtNxtPt](https://discourse.julialang.org/u/jjAtNxtPt)\
**Replies:** 12\
**Last updated:** [April 18, 2024, 7:36pm UTC](https://discourse.julialang.org/t/can-dataframesmeta-replace-dummy-values-for-all-columns-of-a-specific-type/113149 "2024-04-18T19:36:46Z")

</div>

I’ve been trying to figure out a way to have DataFramesMet perform this operation: transform!(df2, names(df2, String) .=\> (t -\> replace(t, ""=\>missing)), renamecols=false) General: Replace dummy value for all columns …

---

## [Jacobian in TangentDynamicalSystem](https://discourse.julialang.org/t/jacobian-in-tangentdynamicalsystem/113140)

<div class="topic-metadata">

**Author:** [@pclus](https://discourse.julialang.org/u/pclus)\
**Replies:** 9\
**Last updated:** [April 18, 2024, 2:13pm UTC](https://discourse.julialang.org/t/jacobian-in-tangentdynamicalsystem/113140 "2024-04-18T14:13:08Z")

</div>

This is a doubt about the definition of TangentDynamicalSystem in DynamicalSystemsBase. In the documentation it is specified the following about the Jacobian: Jacobian The keyword J provides the Jacobian function. It…

---

## [How do I implement the fastest tensor contractions](https://discourse.julialang.org/t/how-do-i-implement-the-fastest-tensor-contractions/111007)

<div class="topic-metadata">

**Author:** [@Laura](https://discourse.julialang.org/u/Laura)\
**Replies:** 11\
**Last updated:** [April 18, 2024, 1:40pm UTC](https://discourse.julialang.org/t/how-do-i-implement-the-fastest-tensor-contractions/111007 "2024-04-18T13:40:53Z")

</div>

I am writing a program which has a tensor contraction with a 4d symmetrical tensor at it’s core. Needless to say, since it will be used inside a non linear problem solver in the future, I need this tensor contraction to …

---

## [\[BoundaryValueDiffEq.jl\] Avoid recompilation](https://discourse.julialang.org/t/boundaryvaluediffeq-jl-avoid-recompilation/113131)

<div class="topic-metadata">

**Author:** [@bmxam](https://discourse.julialang.org/u/bmxam)\
**Replies:** 1\
**Last updated:** [April 18, 2024, 12:25pm UTC](https://discourse.julialang.org/t/boundaryvaluediffeq-jl-avoid-recompilation/113131 "2024-04-18T12:25:19Z")

</div>

Hi, I am trying to use the TwoPointBVPProblem from BoundaryValueDiffEq. I put my code in a file and runs it by including in the REPL. The code runs great but the first call to solve always triggers a (long) “recompilati…

---

## [Excess precompilations](https://discourse.julialang.org/t/excess-precompilations/113144)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 0\
**Last updated:** [April 18, 2024, 11:47am UTC](https://discourse.julialang.org/t/excess-precompilations/113144 "2024-04-18T11:47:51Z")

</div>

These 4 steps each one precompiles the code 1- using GMT from normal REPL 2- using GMT from VSC REPL (???) 3- \] test GMT 4- From pythoncall, jl.seval("using GMT") Looking at the .julia\\compiled\\v1.10\\GMT there are n…

---

## [Packages for Quadtrees in Julia?](https://discourse.julialang.org/t/packages-for-quadtrees-in-julia/113078)

<div class="topic-metadata">

**Author:** [@dgleich](https://discourse.julialang.org/u/dgleich)\
**Replies:** 7\
**Last updated:** [April 18, 2024, 10:36am UTC](https://discourse.julialang.org/t/packages-for-quadtrees-in-julia/113078 "2024-04-18T10:36:04Z")

</div>

I’m trying to port some the d3 graph interaction packages to Julia. (see the nascent GitHub - dgleich/GraphPlayground.jl: Really playing with graphs in Julia via an interactive Makie window. repo …) The next step in the…

---

## [Flux with Metal backend slower than on CPU (Apple M2 Pro)](https://discourse.julialang.org/t/flux-with-metal-backend-slower-than-on-cpu-apple-m2-pro/113080)

<div class="topic-metadata">

**Author:** [@pat-alt](https://discourse.julialang.org/u/pat-alt)\
**Replies:** 5\
**Last updated:** [April 18, 2024, 9:40am UTC](https://discourse.julialang.org/t/flux-with-metal-backend-slower-than-on-cpu-apple-m2-pro/113080 "2024-04-18T09:40:57Z")

</div>

This might be a very silly question (so apologies in advance!), but I have found little discussion on this topic anywhere. I have yet to actually make of my Mac’s M2 GPU using Flux with the Metal.jl backend. But every t…

---

## [Multithreading problems in running Julia in a Slurm cluster](https://discourse.julialang.org/t/multithreading-problems-in-running-julia-in-a-slurm-cluster/112826)

<div class="topic-metadata">

**Author:** [@maphdze](https://discourse.julialang.org/u/maphdze)\
**Replies:** 8\
**Last updated:** [April 18, 2024, 7:34am UTC](https://discourse.julialang.org/t/multithreading-problems-in-running-julia-in-a-slurm-cluster/112826 "2024-04-18T07:34:03Z")

</div>

Hi! I am confused about running Julia code in a Slurm cluster. I am solving a nonlinear PDE so I have to solve it step by step. In each step a linear equation system Ax=b (from FEM so A is sparse) is solved by \\ which …

---

## [Possible to change the global RNG to a custom RNG?](https://discourse.julialang.org/t/possible-to-change-the-global-rng-to-a-custom-rng/113008)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 4\
**Last updated:** [April 18, 2024, 5:38am UTC](https://discourse.julialang.org/t/possible-to-change-the-global-rng-to-a-custom-rng/113008 "2024-04-18T05:38:27Z")

</div>

All my (BetaML) stochastic functions accept a RNG parameter, defaulting to Random.GLOBAL\_RNG. Now, in a certain project I am ok to trade off RN production efficiency with stability and use StableRNGs, but I would like t…

---

## [Compiler recursion limit](https://discourse.julialang.org/t/compiler-recursion-limit/112698)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 10\
**Last updated:** [April 17, 2024, 11:52pm UTC](https://discourse.julialang.org/t/compiler-recursion-limit/112698 "2024-04-17T23:52:55Z")

</div>

I’ve written some recursive code that compiles away due to (I believe) constant propagation. However, I’m afraid that if I run the code on a larger problem I will hit a compiler recursion limit and it will no longer comp…

---

## [DrWatson and NamedTuples](https://discourse.julialang.org/t/drwatson-and-namedtuples/113007)

<div class="topic-metadata">

**Author:** [@wave\_and\_matter](https://discourse.julialang.org/u/wave_and_matter)\
**Replies:** 2\
**Last updated:** [April 17, 2024, 9:50pm UTC](https://discourse.julialang.org/t/drwatson-and-namedtuples/113007 "2024-04-17T21:50:51Z")

</div>

I have been using DrWatson for a project at work for months now and have found it mostly helpful. However, there is one thing I do not understand: As far as I understand, it is more efficient in many cases to use Named…

---

## [Alias two macros](https://discourse.julialang.org/t/alias-two-macros/113028)

<div class="topic-metadata">

**Author:** [@mancolric](https://discourse.julialang.org/u/mancolric)\
**Replies:** 6\
**Last updated:** [April 17, 2024, 6:57pm UTC](https://discourse.julialang.org/t/alias-two-macros/113028 "2024-04-17T18:57:21Z")

</div>

I would like to define a macro such that @mymacro expression is the same as @tturbo @. expression. Is there any way to do this? I have read the documentation and made several attempts, but I am completely new to macros a…

---

## [Tick size in Plots.jl](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793)

<div class="topic-metadata">

**Author:** [@Gabrielmlando](https://discourse.julialang.org/u/Gabrielmlando)\
**Replies:** 6\
**Last updated:** [April 17, 2024, 5:59pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793 "2024-04-17T17:59:48Z")

</div>

I am having a very hard time trying to increase tick size in Plots.jl using gr(). Apparently there is no documentation on this either. Is there a way to do it?

---

## [Any way to call \`getindex(v, end)\`?](https://discourse.julialang.org/t/any-way-to-call-getindex-v-end/113056)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 7\
**Last updated:** [April 17, 2024, 4:35pm UTC](https://discourse.julialang.org/t/any-way-to-call-getindex-v-end/113056 "2024-04-17T16:35:17Z")

</div>

If we have a vector v we can get the last element with v\[end\]. However that seems not to work with the equivalent getindex: julia\> v = rand(3); julia\> v\[end\]; # works julia\> getindex(v , end) #errors ERROR: ParseErro…

---

## [Isfile() for JLD2 appears to be giving segmentation faults / bus errors on a computer cluster](https://discourse.julialang.org/t/isfile-for-jld2-appears-to-be-giving-segmentation-faults-bus-errors-on-a-computer-cluster/113019)

<div class="topic-metadata">

**Author:** [@andrewkhardy](https://discourse.julialang.org/u/andrewkhardy)\
**Replies:** 5\
**Last updated:** [April 17, 2024, 4:15pm UTC](https://discourse.julialang.org/t/isfile-for-jld2-appears-to-be-giving-segmentation-faults-bus-errors-on-a-computer-cluster/113019 "2024-04-17T16:15:27Z")

</div>

I’m posting a question because I’m not sure if I’m making a silly mistake, or if there’s something a bit more subtle going wrong. I am running a Julia script on a HPC cluster. One aspect of this script is that it checks…

---

## [How to interrupt fun(a,b) in a for loop after 10 seconds?](https://discourse.julialang.org/t/how-to-interrupt-fun-a-b-in-a-for-loop-after-10-seconds/112951)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 27\
**Last updated:** [April 17, 2024, 2:55pm UTC](https://discourse.julialang.org/t/how-to-interrupt-fun-a-b-in-a-for-loop-after-10-seconds/112951 "2024-04-17T14:55:06Z")

</div>

How to interrupt fun(a,b) in a for loop after 10 seconds? If terminated before execution, fun x,y,z=false for i=1:k x,y,z=fun(a,b) ??? 10 sek \> x,y,z=false,false,false end Thank you very much for your help, GPT doesn’…

---

## [Reading Eigen Matrix data from a static library](https://discourse.julialang.org/t/reading-eigen-matrix-data-from-a-static-library/113077)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 0\
**Last updated:** [April 17, 2024, 2:45pm UTC](https://discourse.julialang.org/t/reading-eigen-matrix-data-from-a-static-library/113077 "2024-04-17T14:45:08Z")

</div>

I have a C++ (library and) application using Eigen. There’s some data hard-coded in there, in an Eigen matrix, that I suppose I might be able to load from the compiled static library. I can see the symbol there with nm. …

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

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