# General Usage

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

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

**Page:** 514

---

## [Field insertion in immutable @with\_kw struct](https://discourse.julialang.org/t/field-insertion-in-immutable-with-kw-struct/72373)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 2\
**Last updated:** [December 1, 2021, 1:10pm UTC](https://discourse.julialang.org/t/field-insertion-in-immutable-with-kw-struct/72373 "2021-12-01T13:10:37Z")

</div>

Hi, I am trying to load a @with\_kw struct from a named tuple, but I cannot find a way to associate the fields correctly. I would like to use something like a split operator, but the split operator on a named tuple retu…

---

## [Type annotations with abstract types (or when is \`\<:\` required?)](https://discourse.julialang.org/t/type-annotations-with-abstract-types-or-when-is-required/72364)

<div class="topic-metadata">

**Author:** [@cbrnr](https://discourse.julialang.org/u/cbrnr)\
**Replies:** 7\
**Last updated:** [December 1, 2021, 12:58pm UTC](https://discourse.julialang.org/t/type-annotations-with-abstract-types-or-when-is-required/72364 "2021-12-01T12:58:06Z")

</div>

Let’s assume I define a function f with two parameters x and n, where x should be a vector of integer numbers and n should be an integer. I though that I could use the abstract Integer type to write the following functio…

---

## [Problem with Plots using Julia V1.7.0 and VS Code](https://discourse.julialang.org/t/problem-with-plots-using-julia-v1-7-0-and-vs-code/72363)

<div class="topic-metadata">

**Author:** [@Carsten](https://discourse.julialang.org/u/Carsten)\
**Replies:** 3\
**Last updated:** [December 1, 2021, 12:15pm UTC](https://discourse.julialang.org/t/problem-with-plots-using-julia-v1-7-0-and-vs-code/72363 "2021-12-01T12:15:34Z")

</div>

Using Julia version 1.6.4 and VS Code and running the following code using Plots x = 1:10; y = rand(10) plot(x, y) end I get the expected graph in the plot pane. However running the same code with Julia version 1.7.0 …

---

## [How to inherit packages from Julia 1.6.4?](https://discourse.julialang.org/t/how-to-inherit-packages-from-julia-1-6-4/72362)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 2\
**Last updated:** [December 1, 2021, 12:15pm UTC](https://discourse.julialang.org/t/how-to-inherit-packages-from-julia-1-6-4/72362 "2021-12-01T12:15:31Z")

</div>

I have installed Julia 1.7.0. But it does not recognize (load) the packages installed in the previous Version Julia 1.6.4. (@v1.7) pkg\> up Updating registry at \`C:\\Users\\Hermesr\\.julia\\registries\\General\` Updati…

---

## [Strange allocations in broadcasting (with \`^\`?)](https://discourse.julialang.org/t/strange-allocations-in-broadcasting-with/72229)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [December 1, 2021, 11:51am UTC](https://discourse.julialang.org/t/strange-allocations-in-broadcasting-with/72229 "2021-12-01T11:51:16Z")

</div>

I think d ^ 2 should be optimized into just d \* d (here), so the following two operations should be identical, but the form with ^ allocates with the one with \* does not: julia\> using BenchmarkTools julia\> const a = ra…

---

## [Join parts of a URL - joinpath?](https://discourse.julialang.org/t/join-parts-of-a-url-joinpath/12441)

<div class="topic-metadata">

**Author:** [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Replies:** 16\
**Last updated:** [December 1, 2021, 1:19am UTC](https://discourse.julialang.org/t/join-parts-of-a-url-joinpath/12441 "2021-12-01T01:19:29Z")

</div>

Hello, I’d like to build a url like “http://www.domain.com/get/data” from a Vector parts = \["http://www.domain.com", "get", "data"\] At first sight, on a \*nix system I will do julia\> joinpath(parts...) "http://www.dom…

---

## [Julia Bus Error after wake-up from sleep on linux](https://discourse.julialang.org/t/julia-bus-error-after-wake-up-from-sleep-on-linux/71965)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 7\
**Last updated:** [December 1, 2021, 12:56am UTC](https://discourse.julialang.org/t/julia-bus-error-after-wake-up-from-sleep-on-linux/71965 "2021-12-01T00:56:09Z")

</div>

I run Julia on a Linux machine, the machine has NFS home directories with kerberos security. I have no idea if that is relevant but I mention it because it’s non-standard. Pretty consistently after waking my computer up…

---

## [Mapreduce for binary operations on SparseVector](https://discourse.julialang.org/t/mapreduce-for-binary-operations-on-sparsevector/72173)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 3\
**Last updated:** [November 30, 2021, 11:38pm UTC](https://discourse.julialang.org/t/mapreduce-for-binary-operations-on-sparsevector/72173 "2021-11-30T23:38:10Z")

</div>

SparseArrays has support for mapping a binary function over two SparseVectors. For example here. But, I don’t see similar support for mapreduce. The function linked above can be modified to reduce the output vector as …

---

## [Backslash operator "\\" works differently in REPL versus in function?](https://discourse.julialang.org/t/backslash-operator-works-differently-in-repl-versus-in-function/72318)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 2\
**Last updated:** [November 30, 2021, 8:57pm UTC](https://discourse.julialang.org/t/backslash-operator-works-differently-in-repl-versus-in-function/72318 "2021-11-30T20:57:12Z")

</div>

I have two Array{Float32,2} variables, X1 and X2. Both are 5 by 949. In the REPL, this works: Julia\> X2\\X1 949x949 Array{Float32,2}: \<lots of stuff\> which is what I expect and want. but doing the exact same operation…

---

## [Get output of trig function as a multiple of pi?](https://discourse.julialang.org/t/get-output-of-trig-function-as-a-multiple-of-pi/50229)

<div class="topic-metadata">

**Author:** [@GuidoDipietro](https://discourse.julialang.org/u/GuidoDipietro)\
**Replies:** 12\
**Last updated:** [November 30, 2021, 8:31pm UTC](https://discourse.julialang.org/t/get-output-of-trig-function-as-a-multiple-of-pi/50229 "2021-11-30T20:31:21Z")

</div>

Hi there, I’ve been using the Julia REPL a lot as a calculator for my day to day life (as a student of engineering, this is really helpful, and definitely much more comfortable to use than a Casio calc for simple things,…

---

## [Embed interactive .html plot in documentation using Documenter.jl](https://discourse.julialang.org/t/embed-interactive-html-plot-in-documentation-using-documenter-jl/68890)

<div class="topic-metadata">

**Author:** [@cyrieln](https://discourse.julialang.org/u/cyrieln)\
**Replies:** 1\
**Last updated:** [November 30, 2021, 8:24pm UTC](https://discourse.julialang.org/t/embed-interactive-html-plot-in-documentation-using-documenter-jl/68890 "2021-11-30T20:24:04Z")

</div>

I was wondering if it is possible to embed an interactive .html plot as outputted by Plots plotlyjs() savefig to a documentation page as rendered by Documenter.jl. I tried copy pasting the raw HTML from the plot .html f…

---

## [Where do you use (elaborated) structs?](https://discourse.julialang.org/t/where-do-you-use-elaborated-structs/72303)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 0\
**Last updated:** [November 30, 2021, 3:04pm UTC](https://discourse.julialang.org/t/where-do-you-use-elaborated-structs/72303 "2021-11-30T15:04:41Z")

</div>

In his book Data-Oriented Programming - Unlearning Objects, the author Sharvit gives some guidelines for programming, which at first glance seem to be already baked in the Julia language like the separation of functions …

---

## [Update a variable in an HDF5 file](https://discourse.julialang.org/t/update-a-variable-in-an-hdf5-file/62341)

<div class="topic-metadata">

**Author:** [@davidwallis](https://discourse.julialang.org/u/davidwallis)\
**Replies:** 7\
**Last updated:** [November 30, 2021, 4:37pm UTC](https://discourse.julialang.org/t/update-a-variable-in-an-hdf5-file/62341 "2021-11-30T16:37:59Z")

</div>

Simple problem, but it’s driving me mad. How do I update a dataset in an HDF5 file? Thanks julia\> tp2\[“callParams”\]\[“width”\] :1234: HDF5.Dataset: /callParams/width (file: testproj2.h5 xfer\_mode: 0) julia\> read(tp2\[“c…

---

## [Spurious memory allocation even though @code\_warntype looks fine (no types marked in red)](https://discourse.julialang.org/t/spurious-memory-allocation-even-though-code-warntype-looks-fine-no-types-marked-in-red/22367)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 7\
**Last updated:** [November 30, 2021, 4:24pm UTC](https://discourse.julialang.org/t/spurious-memory-allocation-even-though-code-warntype-looks-fine-no-types-marked-in-red/22367 "2021-11-30T16:24:14Z")

</div>

I have trouble with this piece of code: struct Foo{T,N} a::Array{T,N} l::Int end function Base.iterate(foo::Foo{T,N}) where {T,N} v = Array{Float64,N}(undef,size(foo.a)) k = 0 if k == foo.l; return n…

---

## [Hash and SHA of dictionaries and dataframes](https://discourse.julialang.org/t/hash-and-sha-of-dictionaries-and-dataframes/72301)

<div class="topic-metadata">

**Author:** [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Replies:** 0\
**Last updated:** [November 30, 2021, 2:36pm UTC](https://discourse.julialang.org/t/hash-and-sha-of-dictionaries-and-dataframes/72301 "2021-11-30T14:36:56Z")

</div>

Hello everybody I have code where I need to redo a calculation if a large dataset or model specification change. I have a large number of such datasets. In R I would just use the digest() function which provides a SHA …

---

## [How to get the name of macro calling function?](https://discourse.julialang.org/t/how-to-get-the-name-of-macro-calling-function/72286)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 3\
**Last updated:** [November 30, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-to-get-the-name-of-macro-calling-function/72286 "2021-11-30T13:48:56Z")

</div>

Hey al :slight\_smile: It’s probably easier to ask the question with an example: module M macro m() get\_name\_of\_calling\_function() |\> println get\_name\_of\_calling\_module() |\> println end function f() @m() …

---

## [@time every evaluation in repl](https://discourse.julialang.org/t/time-every-evaluation-in-repl/72275)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 7\
**Last updated:** [November 30, 2021, 1:09pm UTC](https://discourse.julialang.org/t/time-every-evaluation-in-repl/72275 "2021-11-30T13:09:52Z")

</div>

Is it possible to hook the repl to @time every eval?

---

## [Strange way to recover performance with polymorphic types](https://discourse.julialang.org/t/strange-way-to-recover-performance-with-polymorphic-types/72250)

<div class="topic-metadata">

**Author:** [@peremato](https://discourse.julialang.org/u/peremato)\
**Replies:** 5\
**Last updated:** [November 30, 2021, 8:57am UTC](https://discourse.julialang.org/t/strange-way-to-recover-performance-with-polymorphic-types/72250 "2021-11-30T08:57:43Z")

</div>

This is a followup of dramatic performance change by adding additional unused method. The explanation was the existing limit on the number of overloaded methods the Julia optimizer is looking to decide the actual return …

---

## [Incorrect result from \`floor\` function](https://discourse.julialang.org/t/incorrect-result-from-floor-function/72262)

<div class="topic-metadata">

**Author:** [@eshanuniyal](https://discourse.julialang.org/u/eshanuniyal)\
**Replies:** 10\
**Last updated:** [November 30, 2021, 7:05am UTC](https://discourse.julialang.org/t/incorrect-result-from-floor-function/72262 "2021-11-30T07:05:33Z")

</div>

I was working on a Project Euler problem and discovered what looks like a bug in the floor function; with some large numbers d, floor(Int, d/9) seems to round up instead of down. I haven’t looked into it too much, but on…

---

## [Why does Dates allow non-broadcasted arithmatic?](https://discourse.julialang.org/t/why-does-dates-allow-non-broadcasted-arithmatic/13205)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 6\
**Last updated:** [November 30, 2021, 3:27am UTC](https://discourse.julialang.org/t/why-does-dates-allow-non-broadcasted-arithmatic/13205 "2021-11-30T03:27:41Z")

</div>

https://github.com/JuliaLang/julia/blob/f8d82ccba81223c9d0d43e4077acb2a208bedc7a/stdlib/Dates/src/arithmetic.jl#L94 In the code for Dates there is the following: # TimeType, AbstractArray{TimeType} (-)(x::AbstractArray…

---

## [Performance of custom lt function in sort!](https://discourse.julialang.org/t/performance-of-custom-lt-function-in-sort/72264)

<div class="topic-metadata">

**Author:** [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Replies:** 2\
**Last updated:** [November 30, 2021, 2:43am UTC](https://discourse.julialang.org/t/performance-of-custom-lt-function-in-sort/72264 "2021-11-30T02:43:21Z")

</div>

I am interested in writing my own lt function within a sort for better performance in a specific use case (in this case, I only care if the numbers are a set length apart from one another). However, it seems that any sub…

---

## [View with single value](https://discourse.julialang.org/t/view-with-single-value/28762)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 14\
**Last updated:** [November 30, 2021, 1:03am UTC](https://discourse.julialang.org/t/view-with-single-value/28762 "2021-11-30T01:03:07Z")

</div>

I want to pass a single value from an array to a function, and I thought this could be faster using view. However, since view returns not an integer but an array, if the function receives an integer at that position, the…

---

## [Turing model fail due to extreme outliers sampled in Exponential distribution?](https://discourse.julialang.org/t/turing-model-fail-due-to-extreme-outliers-sampled-in-exponential-distribution/72174)

<div class="topic-metadata">

**Author:** [@amit1](https://discourse.julialang.org/u/amit1)\
**Replies:** 14\
**Last updated:** [November 29, 2021, 11:16pm UTC](https://discourse.julialang.org/t/turing-model-fail-due-to-extreme-outliers-sampled-in-exponential-distribution/72174 "2021-11-29T23:16:31Z")

</div>

I am modelling some textbook models (minimal example given below) using Turing # Data =================== contact = \[1, 1, 1, 2, 2, 2, 2, 1, 2, 1\] total\_tools = \[ 13 ,22 ,24 ,43 ,33 ,19 ,40 ,28 ,55 ,71\] population = \[1…

---

## [How to get padding between axis label and ticks with VegaLite.jl?](https://discourse.julialang.org/t/how-to-get-padding-between-axis-label-and-ticks-with-vegalite-jl/72249)

<div class="topic-metadata">

**Author:** [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Replies:** 1\
**Last updated:** [November 29, 2021, 11:13pm UTC](https://discourse.julialang.org/t/how-to-get-padding-between-axis-label-and-ticks-with-vegalite-jl/72249 "2021-11-29T23:13:33Z")

</div>

I am having an issue with VegaLite.jl where the label is overlapping with the ticks in the y-axis. I haven’t been able to find any parameter to add some padding between the two values. CC: @davidanthoff

---

## [Check if already compiled](https://discourse.julialang.org/t/check-if-already-compiled/72259)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 0\
**Last updated:** [November 29, 2021, 11:00pm UTC](https://discourse.julialang.org/t/check-if-already-compiled/72259 "2021-11-29T23:00:24Z")

</div>

Is it possible to check if an expression f(x1, x2) will need to compile more or if it has already been compiled?

---

## [Performance of simple broadcasting operations with many arguments](https://discourse.julialang.org/t/performance-of-simple-broadcasting-operations-with-many-arguments/72213)

<div class="topic-metadata">

**Author:** [@Marco\_Lombardi](https://discourse.julialang.org/u/Marco_Lombardi)\
**Replies:** 15\
**Last updated:** [November 29, 2021, 10:09pm UTC](https://discourse.julialang.org/t/performance-of-simple-broadcasting-operations-with-many-arguments/72213 "2021-11-29T22:09:48Z")

</div>

I am puzzled by some microbenchmarks tests I did on very simple broadcasting operations. julia\> using BenchmarkTools julia\> n = 10000; x = rand(n); y = rand(n); z = rand(n); t = rand(n); r = zeros(n); julia\> @belapsed $…

---

## [Unable to make mechanism floating with RigidBodyDynamics](https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221)

<div class="topic-metadata">

**Author:** [@bbokser](https://discourse.julialang.org/u/bbokser)\
**Replies:** 1\
**Last updated:** [November 29, 2021, 7:28pm UTC](https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221 "2021-11-29T19:28:51Z")

</div>

I’m using RigidBodyDynamics and am trying to get my mechanism to be floating rather than fixed-base. However, when I set floating=true in parse\_urdf, I get a “type QuatRotation has no field w” error after running Mechani…

---

## [MATLABs \`sprandsym\` in Julia](https://discourse.julialang.org/t/matlabs-sprandsym-in-julia/72251)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 1\
**Last updated:** [November 29, 2021, 6:50pm UTC](https://discourse.julialang.org/t/matlabs-sprandsym-in-julia/72251 "2021-11-29T18:50:39Z")

</div>

Hello everyone! I need a function that generates a random sparse matrix of size (n,n) with the following properties: issymmetric isposdef has approximately p \* n^2 non-zero elements (for given p) has a condition numbe…

---

## [How to read MAT files containing strings?](https://discourse.julialang.org/t/how-to-read-mat-files-containing-strings/72217)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [November 29, 2021, 5:15pm UTC](https://discourse.julialang.org/t/how-to-read-mat-files-containing-strings/72217 "2021-11-29T17:15:28Z")

</div>

I have a MAT file containing some variables that store string vectors. Below is one example of such a variable: "HY0802" "HY0807" "HY0811" "HY0812" "HY0825" When I use the MAT.jl package to read the…

---

## [\`findlast()\` with predicate: allocations depending on argument types](https://discourse.julialang.org/t/findlast-with-predicate-allocations-depending-on-argument-types/72246)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 0\
**Last updated:** [November 29, 2021, 4:27pm UTC](https://discourse.julialang.org/t/findlast-with-predicate-allocations-depending-on-argument-types/72246 "2021-11-29T16:27:06Z")

</div>

When I run findlast(y -\> y≤x, xrange), the number of allocations changes depending on the sameness of the type of x and the element type of xrange. Here is an example: julia\> VERSION v"1.6.5-pre.0" julia\> using Benchm…

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

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