# General Usage

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

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

**Page:** 706

---

## [Error when assigning a struct, via broadcast, to an array of structs](https://discourse.julialang.org/t/error-when-assigning-a-struct-via-broadcast-to-an-array-of-structs/46165)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 2\
**Last updated:** [September 7, 2020, 12:54am UTC](https://discourse.julialang.org/t/error-when-assigning-a-struct-via-broadcast-to-an-array-of-structs/46165 "2020-09-07T00:54:09Z")

</div>

I’m assigning a value, a single value, to an array of structs using an array to do the indexing. Let me jump straight to my MWE and the punch line \[1\] x\[ii\] .= a gives an error message, but \[2\] x\[ii\] .= \[a\] does not…

---

## [Escaping expressions within macro calls](https://discourse.julialang.org/t/escaping-expressions-within-macro-calls/46160)

<div class="topic-metadata">

**Author:** [@lucas711642](https://discourse.julialang.org/u/lucas711642)\
**Replies:** 4\
**Last updated:** [September 7, 2020, 12:12am UTC](https://discourse.julialang.org/t/escaping-expressions-within-macro-calls/46160 "2020-09-07T00:12:45Z")

</div>

julia\> macro macro1(expr) esc\_expr = esc(expr) :($expr, $esc\_expr) end; julia\> macro macro2(expr) esc\_expr = esc(expr) :(@foo $expr, $esc\_expr) end; julia\> @mac…

---

## [Add title to Makie plot and maintain previous scene settings](https://discourse.julialang.org/t/add-title-to-makie-plot-and-maintain-previous-scene-settings/43225)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 5\
**Last updated:** [September 6, 2020, 8:38pm UTC](https://discourse.julialang.org/t/add-title-to-makie-plot-and-maintain-previous-scene-settings/43225 "2020-09-06T20:38:20Z")

</div>

I have: using Makie scene = Scene(resolution = (1200, 1400)) lines!(scene, randn(10)) # display(scene) display(title(scene, "Title")) which changes the resolution compared to using just display(scene). What …

---

## [Type instability for singleton tuple argument](https://discourse.julialang.org/t/type-instability-for-singleton-tuple-argument/46147)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 5\
**Last updated:** [September 6, 2020, 4:09pm UTC](https://discourse.julialang.org/t/type-instability-for-singleton-tuple-argument/46147 "2020-09-06T16:09:47Z")

</div>

why do I get type instability for the function (x-\>x.^2).((1,))? if my input argument is a singleton tuple, then @code\_warntype (x-\>x.^2).((1,)) gives │ %4 = Base.materialize(%3)::Tuple{Any} └── return %4 If the…

---

## [Parallelize (pre) compilation?](https://discourse.julialang.org/t/parallelize-pre-compilation/46087)

<div class="topic-metadata">

**Author:** [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Replies:** 10\
**Last updated:** [September 6, 2020, 3:12pm UTC](https://discourse.julialang.org/t/parallelize-pre-compilation/46087 "2020-09-06T15:12:34Z")

</div>

I spend a lot of time staring at \[ Info: Precompiling X messages. AFAICT this process is completely single-threaded. This seems like a bit of a shame. I spent all this money on a nice beefy machine with a bunch of cores,…

---

## [For loop condition filter](https://discourse.julialang.org/t/for-loop-condition-filter/46044)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 4\
**Last updated:** [September 4, 2020, 12:32pm UTC](https://discourse.julialang.org/t/for-loop-condition-filter/46044 "2020-09-04T12:32:28Z")

</div>

Has anybody wanted something like this? for x in 1:10 if x != 5 println(x) end Here’s some less-than-ideal ways: for x in (x for x in 1:10 if x != 5) println(x) end for x in 1:10 x == 5 && continue pr…

---

## [MATLABArrays.jl needed (similar to ElasticArrays.jl)](https://discourse.julialang.org/t/matlabarrays-jl-needed-similar-to-elasticarrays-jl/46108)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 5\
**Last updated:** [September 6, 2020, 9:04am UTC](https://discourse.julialang.org/t/matlabarrays-jl-needed-similar-to-elasticarrays-jl/46108 "2020-09-06T09:04:45Z")

</div>

I’m porting MATLAB code to Julia, and I know about the helpful packages (and the transpiler), I port gradually, and leave some stuff in MATLAB, or by now even Octave. Does anyone know if there’s an array type (in a pack…

---

## [Makie.jl - How to plot a 3D animation?](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-animation/46129)

<div class="topic-metadata">

**Author:** [@yosuga](https://discourse.julialang.org/u/yosuga)\
**Replies:** 0\
**Last updated:** [September 6, 2020, 6:08am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-animation/46129 "2020-09-06T06:08:54Z")

</div>

Hi,I have a question. I would like to ask How to plot a time-evolution of a 3D Gaussian function with Makie.jl. I tried to write a code in reference to a surface-version code of sin( r )/r. 1.Make a model and Solve a …

---

## [Saving PhyloPlots plots](https://discourse.julialang.org/t/saving-phyloplots-plots/45921)

<div class="topic-metadata">

**Author:** [@eckofoid](https://discourse.julialang.org/u/eckofoid)\
**Replies:** 1\
**Last updated:** [September 6, 2020, 12:11am UTC](https://discourse.julialang.org/t/saving-phyloplots-plots/45921 "2020-09-06T00:11:34Z")

</div>

Is there a programmatic way to save a plot generated using PhyloNetworks and PhyloPlots without resorting to R calls? The latter will not accept a file name passed from program arguments, and is, therefore, not very usef…

---

## [When to use StaticArrays](https://discourse.julialang.org/t/when-to-use-staticarrays/46123)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 4\
**Last updated:** [September 5, 2020, 11:11pm UTC](https://discourse.julialang.org/t/when-to-use-staticarrays/46123 "2020-09-05T23:11:31Z")

</div>

I have been looking into StaticArrays.jl to speed up linear algebra but I think I am doing something wrong or testing the wrong things. My first test was a simple linear model: using StaticArrays, Random, BenchmarkTool…

---

## [What is the correct way to access a variable number of workspaces with a variable number of threads?](https://discourse.julialang.org/t/what-is-the-correct-way-to-access-a-variable-number-of-workspaces-with-a-variable-number-of-threads/46111)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 3\
**Last updated:** [September 5, 2020, 8:06pm UTC](https://discourse.julialang.org/t/what-is-the-correct-way-to-access-a-variable-number-of-workspaces-with-a-variable-number-of-threads/46111 "2020-09-05T20:06:23Z")

</div>

Hey all— I am trying to write a good thread-parallel implementation of a problem that can be described quickly like this: The user has to do n tasks, each of which require a workspace. They can provide any number of w…

---

## [Legendfontfamily problem with Plots.jl pyplot() backend](https://discourse.julialang.org/t/legendfontfamily-problem-with-plots-jl-pyplot-backend/46120)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 0\
**Last updated:** [September 5, 2020, 7:36pm UTC](https://discourse.julialang.org/t/legendfontfamily-problem-with-plots-jl-pyplot-backend/46120 "2020-09-05T19:36:11Z")

</div>

Hi, the parameter legendfontfamily=:Courier seems to be (silently) ignored with Plots.plot(…) when I use the pyplot() backend. The parameter is used with gr() but in this case the rest of my plot breaks… Any hint ?

---

## [Reverting a repo: dev + 2\*Manifest + instantiate - resolve = Pkg confusion](https://discourse.julialang.org/t/reverting-a-repo-dev-2-manifest-instantiate-resolve-pkg-confusion/46076)

<div class="topic-metadata">

**Author:** [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Replies:** 9\
**Last updated:** [September 5, 2020, 7:29pm UTC](https://discourse.julialang.org/t/reverting-a-repo-dev-2-manifest-instantiate-resolve-pkg-confusion/46076 "2020-09-05T19:29:51Z")

</div>

I’m using Pkg.dev to develop a package (an application, not a library) on a local path. I commit the package Manifest into my repo so I can revert and run instantiate in case I mess up my package dependencies. That happ…

---

## [How to stop taking gradient of neural network in Flux.jl?](https://discourse.julialang.org/t/how-to-stop-taking-gradient-of-neural-network-in-flux-jl/46062)

<div class="topic-metadata">

**Author:** [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Replies:** 1\
**Last updated:** [September 5, 2020, 5:27pm UTC](https://discourse.julialang.org/t/how-to-stop-taking-gradient-of-neural-network-in-flux-jl/46062 "2020-09-05T17:27:09Z")

</div>

This is my neural network: net = Chain(Dense(6, 16, relu), Dense(16, 16, relu), Dense(16, 8)) Consider that I have a function like: f(x) = sum(net(x)) If I want to stop taking gradient of f(x) with respect to x, I on…

---

## [Struggling to interpret spherical harmonic transforms from FastTransforms.jl](https://discourse.julialang.org/t/struggling-to-interpret-spherical-harmonic-transforms-from-fasttransforms-jl/45986)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [September 5, 2020, 3:30pm UTC](https://discourse.julialang.org/t/struggling-to-interpret-spherical-harmonic-transforms-from-fasttransforms-jl/45986 "2020-09-05T15:30:57Z")

</div>

I am trying to compute the spherical harmonic transform of a function that is given by sin(θ)cos(ϕ) on the face of the sphere facing us, and zero on the other face that is away from us. I am attempting to use FastTransfo…

---

## [Is there any limitation on threads' num for cpu without SMT？](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104)

<div class="topic-metadata">

**Author:** [@N5N3](https://discourse.julialang.org/u/N5N3)\
**Replies:** 2\
**Last updated:** [September 5, 2020, 3:01pm UTC](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104 "2020-09-05T15:01:52Z")

</div>

I’m using 9600KF with 6 cores and 6 threads, the following confuse me: If I start julia with 6 threads, then the cost of schedule(t::Task) = enq\_work(t) increases sharply somtime, while everythings seems ok with thread…

---

## [Vector adjoint and indexing don't commute?](https://discourse.julialang.org/t/vector-adjoint-and-indexing-dont-commute/45980)

<div class="topic-metadata">

**Author:** [@timmor](https://discourse.julialang.org/u/timmor)\
**Replies:** 19\
**Last updated:** [September 5, 2020, 12:29pm UTC](https://discourse.julialang.org/t/vector-adjoint-and-indexing-dont-commute/45980 "2020-09-05T12:29:19Z")

</div>

I was surprised that vector adjoint doesn’t commute with indexing. x = \[1:5;\] x\[1:3\]' # is a 1x3 Adjoint x'\[1:3\] # is a 3 element Vector For example if I set y = x' my mental model of y is “row vector”, and I was think…

---

## [Question about Image output](https://discourse.julialang.org/t/question-about-image-output/46055)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 4\
**Last updated:** [September 5, 2020, 3:54am UTC](https://discourse.julialang.org/t/question-about-image-output/46055 "2020-09-05T03:54:30Z")

</div>

May I ask if Julia can realize dynamic 3D map? For example, you can interact with the mouse or rotate advanced images by yourself. thank you！！

---

## [Generate new array using conditional selections from existing arrays](https://discourse.julialang.org/t/generate-new-array-using-conditional-selections-from-existing-arrays/46081)

<div class="topic-metadata">

**Author:** [@yold6](https://discourse.julialang.org/u/yold6)\
**Replies:** 2\
**Last updated:** [September 4, 2020, 10:43pm UTC](https://discourse.julialang.org/t/generate-new-array-using-conditional-selections-from-existing-arrays/46081 "2020-09-04T22:43:41Z")

</div>

Hello, I am attempting to generate an new array C by using conditional selections from two existing DataFrames (A and B). The first pre-existing DataFrame (A) is 18 x 18 and contains Float64 values that I would like to…

---

## [Continue a loop in Julia when the time out](https://discourse.julialang.org/t/continue-a-loop-in-julia-when-the-time-out/46002)

<div class="topic-metadata">

**Author:** [@yangqifan](https://discourse.julialang.org/u/yangqifan)\
**Replies:** 6\
**Last updated:** [September 4, 2020, 1:58pm UTC](https://discourse.julialang.org/t/continue-a-loop-in-julia-when-the-time-out/46002 "2020-09-04T13:58:25Z")

</div>

When I use the DifferentialEquations.jl to solve a ODEs, some parameters set is time-consuming. I have write a loop to solve the ODEs at diverse parameters. I want to early terminate the time-consuming parameters set, fo…

---

## [Regular expression How do I find a line that contains this rule but also something else?](https://discourse.julialang.org/t/regular-expression-how-do-i-find-a-line-that-contains-this-rule-but-also-something-else/46010)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 10\
**Last updated:** [September 4, 2020, 1:06pm UTC](https://discourse.julialang.org/t/regular-expression-how-do-i-find-a-line-that-contains-this-rule-but-also-something-else/46010 "2020-09-04T13:06:38Z")

</div>

How do I find a line that contains this rule but also something else? rx=r"^\[0-9\]{2}-\[0-9\]{3}$" occursin.( rx ,string.(dane\[:,6\])) Thx, Paul

---

## [Build from a master or development branch](https://discourse.julialang.org/t/build-from-a-master-or-development-branch/46056)

<div class="topic-metadata">

**Author:** [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Replies:** 1\
**Last updated:** [September 4, 2020, 12:51pm UTC](https://discourse.julialang.org/t/build-from-a-master-or-development-branch/46056 "2020-09-04T12:51:33Z")

</div>

How can I force BinaryBuilder to make a local build for a development branch? using BinaryBuilder name = "my\_package" version = v"?.?.?" \<= e.g., my\_package#development

---

## [Array{Float64,2} -\> Array{Float64,1}](https://discourse.julialang.org/t/array-float64-2-array-float64-1/45979)

<div class="topic-metadata">

**Author:** [@Jhall7529](https://discourse.julialang.org/u/Jhall7529)\
**Replies:** 5\
**Last updated:** [September 4, 2020, 12:48pm UTC](https://discourse.julialang.org/t/array-float64-2-array-float64-1/45979 "2020-09-04T12:48:41Z")

</div>

When indexing an Array{Float64,2} julia\> A = ones(1,5) 1×5 Array{Float64,2}: 1.0 1.0 1.0 1.0 1.0 julia\> A\[1,2:5\] 4-element Array{Float64,1}: 1.0 1.0 1.0 1.0 Why am I being given an Array{Float64,1}? I’m ex…

---

## [@show\_code macro](https://discourse.julialang.org/t/show-code-macro/46050)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 2\
**Last updated:** [September 4, 2020, 11:50am UTC](https://discourse.julialang.org/t/show-code-macro/46050 "2020-09-04T11:50:45Z")

</div>

Hey :slight\_smile: Is there a @show\_code yet? e.g.: julia\> @show\_code sqrt(1+1) sqrt(1+1) in Main at REPL\[10\]:1 In file.jl 1: 2:@show\_code sqrt(1+1) 3: after running returns: sqrt(1+1) in file.jl:2 So I can do: …

---

## [Fetch value stored in a File or FileTree node on Windows 10](https://discourse.julialang.org/t/fetch-value-stored-in-a-file-or-filetree-node-on-windows-10/46045)

<div class="topic-metadata">

**Author:** [@evad](https://discourse.julialang.org/u/evad)\
**Replies:** 0\
**Last updated:** [September 4, 2020, 8:26am UTC](https://discourse.julialang.org/t/fetch-value-stored-in-a-file-or-filetree-node-on-windows-10/46045 "2020-09-04T08:26:29Z")

</div>

I have stored a dataframe in the following file node. But can’t retrieve it using the get function. What did I do wrong? thanks

---

## [3D Quiver Plot and animation](https://discourse.julialang.org/t/3d-quiver-plot-and-animation/44645)

<div class="topic-metadata">

**Author:** [@sriharitn](https://discourse.julialang.org/u/sriharitn)\
**Replies:** 5\
**Last updated:** [September 4, 2020, 8:47am UTC](https://discourse.julialang.org/t/3d-quiver-plot-and-animation/44645 "2020-09-04T08:47:17Z")

</div>

I’m trying to plot 3D Quiver plot with Julia Plots package, it appears that Plots still does not support 3D Quiver. so I’m trying to see if there are any other packages such as PyPlot that has the facility to plot 3D Qui…

---

## [Julia hangs while displaying an SMatrix](https://discourse.julialang.org/t/julia-hangs-while-displaying-an-smatrix/45918)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 3\
**Last updated:** [September 4, 2020, 7:37am UTC](https://discourse.julialang.org/t/julia-hangs-while-displaying-an-smatrix/45918 "2020-09-04T07:37:29Z")

</div>

The following code hangs on Windows 10 and Julia 1.5.0 on two different computers: using StaticArrays struct Points{N,T\<:Number} p::SMatrix{3,N,T} end Points(x::Matrix{T}) where {T} = Points{size(x,2),T}(x) points…

---

## [Error when installing registry](https://discourse.julialang.org/t/error-when-installing-registry/45999)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 5\
**Last updated:** [September 4, 2020, 6:13am UTC](https://discourse.julialang.org/t/error-when-installing-registry/45999 "2020-09-04T06:13:22Z")

</div>

When you did the update, the following alert is displayed :. pkg\>up Installing known registries into C:\\Users\\hermesr\\.julia ERROR: SystemError: opening file “C:\\Users\\hermesr\\.julia\\registries\\General\\Registry.toml”:…

---

## [How to use cases in docstring math mode?](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 2\
**Last updated:** [September 4, 2020, 5:36am UTC](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039 "2020-09-04T05:36:03Z")

</div>

I am using Documenter.jl to generate the documentation, and would like to use \\cases to define piecewise functions. Currently I am adding the equation to the docstring. Something like this doesn’t seem to render as latex…

---

## [How to prevent memory build-up?](https://discourse.julialang.org/t/how-to-prevent-memory-build-up/45929)

<div class="topic-metadata">

**Author:** [@adevaucorbeil](https://discourse.julialang.org/u/adevaucorbeil)\
**Replies:** 11\
**Last updated:** [September 4, 2020, 1:42am UTC](https://discourse.julialang.org/t/how-to-prevent-memory-build-up/45929 "2020-09-04T01:42:01Z")

</div>

Hi there, I have a complex modeling code that involves a while loop which could be run a million times. In this loop, there are many, but some no-so complex mathematical operations involving SVectors and Arrays of SVect…

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

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